Javascript measurements, window.onload, and getimagesize
If you use a lot of javascript for animations / measurements (like I do), it can be very useful to include the width and the height of any images you use in your <img/> tags. This will make sure that width / height measurements taken by your javascript are accurate before waiting for all of the images to load. This leaves you free to run your code as soon as the dom is ready, without worrying about remeasuring once window.onload fires.
A teensy bit of php will take care of this for you if you do not already know the image size, or don’t care to look into it:
code!
<img alt="i am lazy" src="/images/myImage.jpg" <?php list($w,$h) = getimagesize($path_to_image); echo "width=\"$w\" height=\"$h\""; ?>/>













Leave a Reply
ok to use:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
bonus!
If you want to post code, you can use:
<pre lang="[language]">[code]</pre>
Where [language] is a valid geshi language type, and where [code] is your code.