Reputation: 3277
Is there a way to get an image dimensions using javascript or jquery? I'm trying to get an image size from a folder on my server, but I can't use php since I have around 50+ images that need's to have the image dimension checked. Are there plugins or functions that I could use to get an image dimension?
Upvotes: 1
Views: 538
Reputation: 2265
$("img").each(function()
{
console.log(this.width());
console.log(this.height());
});
Upvotes: 0
Reputation: 15836
this plugin should help you :
https://github.com/desandro/imagesloaded
$("#loaded_image").imagesLoaded(function(){
console.log( $(this).width() )
console.log( $(this).height() )
});
However if you want to get the info before you load the image using PHP , then refer to here :
http://php.net/manual/en/function.getimagesize.php
Upvotes: 2
Reputation: 6565
Sample code available in internet
<?php
list($width, $height, $type, $attr) = getimagesize("image_name.jpg");
echo "Image width " .$width;
echo "<BR>";
echo "Image height " .$height;
echo "<BR>";
echo "Image type " .$type;
echo "<BR>";
echo "Attribute " .$attr;
?>
Upvotes: 0