[thelist] Automatically Size User-Loaded Images

DAVID FIELDS d.fields at nr.cc.mn.us
Tue Oct 30 11:20:20 CST 2001

  I see us basically using this as a way to limit the image size
  so that it doesn't create horizontal scroll-bars, etc.

If that's your primary concern, and these photos will be displayed on a coded-by-you site, then the quick&dirtiest approach is simply to [in your display pages] hardcode the image size and leave the src as a variable, such as:

  <img src="[pathtoimagefile]" width="400" height="265" />

It's not the most professional method, because perceived image quality often takes a severe nosedive when you alter actual image size in the code. If the images you're pulling into the page aren't originally 400x265, for example, you may see some pixelation, distortion or jaggies. But it takes care of the "must display no bigger than this" problem.

<tip type="attribute ordering" author="David Fields">
Always code your attributes in consistent order. It'll save you many minutes when reading and even more when search-and-replacing. For example, in <img /> tags I'll first put size attributes (width, height), then alignment, then whatever else . . . it's not so important which way you do it, just that you're consistent over your entire project (bonus points for being consistent among *all* your projects).

Blessed are the handcoders who use Dreamweaver also, for they shall go home early.
David Fields  |  http://www/spinplate.com/doc

More information about the thelist mailing list