My Services

Blog: Zen Cart Rule #2: Additional Images' Names


From “Animal Farm”, by George Orwell:

All animals are equal, but some are more equal than others.

You’ve got your Zen Cart set up and have been placing all your products’ images in the base images’ folder (/images). It’s getting hard to maintain all those images in a single folder (and it’s surely increasing your page-load times), so you’ve decided to move all the product images into manufacturer-based sub-directories.

Good plan! Now you’ve updated each of the products’ database records to properly point to the primary image that’s now in an images’ sub-directory (e.g. images/microsoft) and have copied all those additional product images as well. You fire up your store with those relocated images and … what the heck … many of your additional images have “gone missing”. You re-check that the additional-image files have, in fact, been copied to their manufacturer sub-directory — they’re there!

One of the “problem” products uses base image name of my_image.jpg and it’s got two additional images: my_image-01.jpg and my_image-02.jpg. There’s the issue — all additional images are equal, but some are more equal than others!

The additional-images’ handling (/includes/modules/additional_images.php) uses different criteria when the base image is in a sub-directory than in the main /images directory!  When a main product image is in a sub-directory, its additional images’ file-names are of the form base_suffix.ext; when the main image is in the root /images directory, no intervening underscore is required.

So, given the example above, the file my_image-01.jpg is a perfectly-acceptable additional image for the file my_image.jpg … when the main image is in the /images directory itself … but not when the main image is in a sub-directory.  The file my_image_01.jpg is a valid additional image for my_image.jpg, regardless the directory in which the main image resides.

Now that you know the additional-images’ naming rules, it’s easier to play the game! Happy Zenning!

Copyright © 2012-2022 Vinos de Frutas Tropicales. Powered by Zen Cart