Displaying dimensions of each image as caption or label
I want to loop through each image on a page...
For each image, get the height and width of the image, and display it as
either a caption or label or free-text, located above or below or next-to
the image. The display method (caption, label, free-text) and location
don't matter, whichever is easiest is OK.
I know how to loop through all "image" elements and call a function. I
just need to know how to get the image dimensions (is it just image.width,
image.height?), and then how to display that information on the page near
each image. I'll keep the display text simple, just "width x height",
like: 220 x 144 or 220w x 144h.
I'm not worried about making sure the images are loaded, because I'll
execute the loop after "onload", or actually, more likely, by a button
press.
No comments:
Post a Comment