Get image height that is not in content

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:

Read More

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.

Related posts

Leave a Reply

2 comments

  1. image by only using the URL of the image?

    var img = new Image();
    img.onload = function() {
        alert('The size is ' + this.width + 'x' + this.height);
    };
    img.src = 'some image URL';
    

    Try it
    http://jsfiddle.net/NPSMN/

    ps:

    I tried this: … where
    catch_that_image() returns the URL, but somehow this doesn’t work (I
    think the first echo breaks it). Any ideas?

    did you look closer at your code? echo outputs to the browser, not to the argument of the function.

    <?php 
    list(,$height) = getimagesize(catch_that_image()); 
    echo "<p>$height</p>"; 
    ?>