Posted By

AdrianShort on 04/24/08


Tagged

images getimagesize


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

luman
basicmagic
vali29


Automatic image width and height tags


 / Published in: PHP
 

The lazy way to generate XHTML-valid width and height attributes for your images. This is incredibly inefficient, though I believe (ref?) that calls to getimagesize() are cached.

  1. <img src="path/to/mypic.jpg" <?php $a = @getimagesize("path/to/mypic.jpg"); echo $a[3]; ?> alt="My pic" />

Report this snippet  

You need to login to post a comment.