Automatic image width and height tags


/ Published in: PHP
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. <img src="path/to/mypic.jpg" <?php $a = @getimagesize("path/to/mypic.jpg"); echo $a[3]; ?> alt="My pic" />

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.