On May 19, 2004, at 3:12 PM, David Blomstrom wrote:
Suppose I have a field that stores links that look
like this:

<img src="<?php echo "$seg" ?>images/states/ak.gif"
width="100" height="75" />
<img src="<?php echo "$seg" ?>images/states/wy.gif"
width="100" height="75" />

and another field that stores image links that look
like this:

<img src="<?php echo "$seg" ?>images/maps/ak.gif"
width="100" height="75" />
<img src="<?php echo "$seg" ?>images/maps/wy.gif"
width="100" height="75" />

It's better to have a central config file that defines all your paths as variables. No need to embed hard paths in your links either in code or stored in the db.


I do mockup with a GUI which creates paths, but then apply a gobal search & replace to change the src to variable plus the file name.

So, even your images/maps/ component can be a var.

then all I have to do is replace $seg with the path to
the image folder to display my images. The images
don't even have to be the same size, since I have to
enter each state's image individually, anyway.

If the images are pre-defined standards, then yeah, entering the size in the db is probably as good a way as any if they're different sizes. However, if you have a bucnh of standard image slots to be filled with images of all the same size, then you can set those as PHP vars defined in config file. Another method is to embed the size in the file name, and parse the file name when it is retrieved from the db. Finally, if the images are being uploaded, use a tool like imagemagick to acquire the image properties at that time and store them. Then your sizes can be vars too.


And I could even create a field that anticipates a
future series of images in an as yet unspecified
folder:

<img src="<?php echo "$seg" ?>images/<?php echo
"$WHAT" ?>/ak.gif" width="100" height="75" />

If I then create a series of images in a folder named
landscapes - or nature/landscapes - then I would use
PHP to replace WHAT with nature/landspaces.

Yep. That can be done in the db or in a univeral config file your middleware reads depending on what makes the most sense.


-- greg willits


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to