On Wed, 3 Oct 2001, Nick Lo wrote:

> However an issue that has me holding back is the fact that in a site even
> with as few as 100 products (which equals 300 item images) there needs to be
> a way of organising those images into separate directories. From my
> experience of a client using upload image in Miva Merchant they ended up
> with an unmanageable directory full of thousands of images (including
> errors).

The way I've done it before is to name the images according to the item
number, like so: (for item #312)

p312s.jpg (small thumbnail)
p312m.jpg (normal)
p312l.jpg (large image that opens in a pop-up)

(the "p" is for "product" -- there are other types of images in there too,
like "c" categories and "b" banners)

This naming happens automatically when the image is uploaded, so it doesn't
matter what the file was named on the client side -- there can't be mistakes
in naming.  When a user goes to view the item page, the code checks if there
is an image file with that products id, and shows it if there is.

This makes for a giant directory of somewhat obscurely named images, but you
should never have to even look at the filenames because it's all managed
through the web interface.  If you are adding large numbers (100's) of
images at once, you can run them through a script (to resize them to the
three sizes, for instance) and generate the appropriate names automatically
(starting with a file like "312.tiff") and then don't have to do it all
through the web for each item.

- Isaac

p.s. the code itself isn't too polished -- it was a probono project and i
was in a hurry!

the basic part of it is code like this in UPDATE_ITEM:

 if (isset($inputGraphicFile) AND $inputGraphicFile != "none")
 {
   copy($inputGraphicFile, ITEM_IMAGES_DIR . "/p" . $item_num . "m.jpg");
 }

and this in the "item" screen:

 $GraphicFile = (ITEM_IMAGES_DIR . "/p" . $DatabaseRowDept->ID . "m.jpg");

and then the normal code that checks that $GraphicFile really exists, what
dimensions it is and makes the correct image tag.  i also added the item
screen code to the admin_item screen, so you can view (and delete) the
images there.

_______________________________________________
FreeTrade-dev mailing list
[EMAIL PROTECTED]
http://share.whichever.com/mailman/listinfo/freetrade-dev

Reply via email to