Results 1 to 2 of 2

Thread: Find image height without it being set in HTML

  1. #1
    Join Date
    Dec 2009

    Find image height without it being set in HTML

    I have found how to find the height of an image, but it seems to rely on the number that is set with the HTML height attribute.
    Is there a way to find the height of an image on the page if it is not set with HTML (using a CMS that isn't setting the height with HTML, don't yell at me for not doing it).
    HTML Code:
    <div class="col" style="border: 1px solid">
    <a style="text-decoration: none;" href="/straight-razors.html">
    <img border="0" src="straightrazors__83594.gif">
    My ultimate goal is to find the height of the tallest image in a group of images, so that I can set a height on the "col" div so that they align properly, so if you want to help with that. Otherwise I just need to know how to get this height and I will figure out the rest.

  2. #2
    Join Date
    Mar 2007
    The height is readable provided that the image has loaded.

    If you load into an <img> tag, the true dimensions are overridden by the height/width attributes if set.

    If you need to get true dimensions under any circumstances, load into an Image() object and use its onload event to read or signal the readability of dimensions.

    Install your onload event handler before applying the src property.
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center