I am building a custom wordpress theme and have a slideshow on the front page displaying images from blog posts.
Now if the image is over 300px in height I want to force its widthand center it vertically. So my question is:
Is there a way, in php or javascript to get the height of an image by only using the URL of the image?
EDIT: I tried this: <?php list($height) = getimagesize(echo catch_that_image()); echo "<p>$height</p>"; ?>
where catch_that_image()
returns the URL, but somehow this doesn’t work (I think the first echo breaks it). Any ideas?
Thank you for your help.
image by only using the URL of the image?
Try it
http://jsfiddle.net/NPSMN/
ps:
did you look closer at your code?
echo
outputs to the browser, not to the argument of the function.See getimagesize() in PHP. That will do what you’re looking for.
http://php.net/manual/en/function.getimagesize.php