I have these images that I am getting off my server and a database using PHP
<div class="pics">
<img src="upload/<?php echo $array['image'] ?>" height="200"/>
</div>
There actual sizes are huge, but I need them to all be at a height at 200.
How do I find the width of this image using jQuery, I cant find a tutorial anywhere....
Any help would be appreciated.
Thanks for you're time, J
I would try .innerWidth()
instead of .width()
, as .width()
would include the margin.
$('img').innerWidth();
If your image is really that big, you should consider scaling it down it server-side.
Actually .width()
is not adding the margin and furthermore its not even adding the padding. That makes .width()
more suitable than .innerWidth()
. Thanks SKS.
Try using .width
function. something like $('img').width();
More reading.. http://api.jquery.com/width/
Further more, there are .innerWidth
and .outerWidth
functions to include/exclude padding,border and margins. See below image for details,