---
title: "Retrieve original image length & height with jquery?"  
description: "Retrieve original image length & height with jquery?"  
author: "Anonymous User"  
published: 2015-01-30  
updated: 2015-01-30  
canonical: https://www.mindstick.com/forum/12919/retrieve-original-image-length-height-with-jquery  
category: "asp.net"  
tags: ["jquery", "html", "css"]  
reading_time: 1 minute  

---

# Retrieve original image length & height with jquery?

I have a display thumbnail at 250px by 250px. I want to be able to [retrieve](https://www.mindstick.com/forum/34400/how-to-retrieve-form-values-in-controller-action) its original [width and height](https://www.mindstick.com/forum/158680/what-css-property-is-used-to-set-the-width-and-height-of-an-element) when clicking on the thumbnail.

I tried doing this:

```
$(function() {    $(".img_section").on('click',function() {        var img = $(this).children(".test_img").attr("src");        theImg.src =img.attr("src");         var imgNaturalWidth = theImg.width();        var imgNaturalHeight = theImg.height();         alert(imgNaturalWidth);        alert(imgNaturalHeight);}) // not working
```

Any help will be appreciated, thanks.

## Replies

### Reply by Anonymous User

```
$(function () {    $(".img_section").on('click',
function () {        $this = $(this).children('img');        var image = new Image();        image.src =$this.attr("src");        image.onload =function () {            alert('width:' + this.width +' '+'height: '+ this.height); /* calculation the width  and height from image onload */        };    });});
```


---

Original Source: https://www.mindstick.com/forum/12919/retrieve-original-image-length-height-with-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
