Forums / Setting Up Categories, Products, Attributes / Small, medium, large versions of product images--I've gotten mixed messages

Small, medium, large versions of product images--I've gotten mixed messages

Started by webkat on 6 Feb 2012, 1:51 PM · Views: 4,830

Results 1 to 20 of 24
6 Feb 2012, 1:51 PM
#1
webkat avatar

webkat

Zen Follower

Join Date:
Jan 2012
Location:
New England
Posts:
238
Plugin Contributions:
0

Small, medium, large versions of product images--I've gotten mixed messages

Ok I know that Zen Cart supports sm/med/lrg image sizes for products, but I've seen differing explanations of how to do it.

One is to use different folders (medium, large, and I guess the product folder is where the small one goes? Let me know).

One is to use _MED and _LRG suffixes to the filenames.

I tried the different folders, though I had also added the suffixes... anyway it didn't work. Neither did putting all the files with suffixes in the same folder.

Am I supposed to put the images with the same filenames (no suffixes) in the different folders by size?

What is the final, real answer here? I'm confused :(

Thanks in advance for your help!

(Oh, and does the same apply for the additional product images? (_01, _02, etc)?

6 Feb 2012, 2:28 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,127
Plugin Contributions:
56

Re: Small, medium, large versions of product images--I've gotten mixed messages

Your \images directory is the starting point for your small images, \images\medium is the starting point for your medium images and \images\large is the starting point for your large images. The _MED and _LRG suffixes are the default values; you can change them in your admin's Configuration->Images.

Let's say that you have a product with an image file named my_picture.jpg. That would result in you having the following files:

\images\my_picture.jpg
\images\medium\my_picture_MED.jpg
\images\large\my_picture_LRG.jpg

If you wanted to have another image for that product, you'd pick another suffix, like _00. Then you'd also have the following files:

\images\my_picture_00.jpg
\images\medium\my_picture_00_MED.jpg
\images\large\my_picture_00_LRG.jpg
6 Feb 2012, 3:26 PM
#3
webkat avatar

webkat

Zen Follower

Join Date:
Jan 2012
Location:
New England
Posts:
238
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

Ok, but when I upload images via the products editing page it puts them in the TG_products folder--is that a problem? Should I be having them all in the base images folder?

6 Feb 2012, 4:43 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Small, medium, large versions of product images--I've gotten mixed messages

That defaults to starting with the base /images/ folder. but you can choose any of the subfolders of /images/ to put the file in when you upload it through the product page. (If you have used other than the regular default once, you should pay close attention to what folder you are using the next time, as it may default to the previous subfolder instead of /images/.)

You do need to be sure that medium images go in the /medium/ folder and large images in the /large/ folder.

TG_products folder Is this a custom subfolder you created or use for certain products? Unless you want/need separate subfolders for different groups of product images, you would be best off just using the base /images/. If you do use custom subfolders, they must be organized like
/images/TG_products/
/images/medium/TG_products/
/images/large/TG_products/

6 Feb 2012, 5:33 PM
#5
webkat avatar

webkat

Zen Follower

Join Date:
Jan 2012
Location:
New England
Posts:
238
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

Yes, it is a custom folder I created to keep the product images separated out from the other images I'm using on the site. I'll try that directory structure and see if it works. thanks!

6 Feb 2012, 6:08 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Small, medium, large versions of product images--I've gotten mixed messages

Since the principal function of the /images/ folder is product images, I would suggest you use the base /images/ for product images and make a subfolder for other images.

If your other images are for use in your template (like fixed images, box corners or backgrounds), they really belong in /includes/templates/your_template/images/.

6 Feb 2012, 6:55 PM
#7
webkat avatar

webkat

Zen Follower

Join Date:
Jan 2012
Location:
New England
Posts:
238
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

Most of the other images are for the informational pages that I have, as illustrations of various things. This site manufactures re-engineered, upgrade parts for a popular piece of exercise equipment, and we have pictures of the old (original) parts, the equipment itself, what kind of damage to look for, etc.

6 Feb 2012, 7:31 PM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Small, medium, large versions of product images--I've gotten mixed messages

Then I would advise using a folder like /images/info/ for these images, and let the product images use the base /images/ and /images/medium/ and /images/large/ folders unencumbered.

7 Feb 2012, 10:09 AM
#9
rafcamera avatar

rafcamera

New Zenner

Join Date:
Mar 2006
Location:
Belarus
Posts:
63
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

Hi. I have bit different problem. Not all additional images show up on the product pages.
I've set blank suffixes for medium and large images, and store large images only allowing system to shrink them as necessary.
So, now I've uploaded product image ob-oks5-18-1.jpg to /images/mcl/ folder using product edit page in admin panel, and

ob-oks5-18-1_all.jpg
ob-oks5-18-1_front.jpg
ob-oks5-18-1_rear.jpg
ob-oks5-18-1_side.jpg

into the same folder using ftp.

When I visit the product page http://rafcamera.com/movie-cameras/lenses-lomo-kmz-zeiss/parts/lomo-18mm-lens-optical-block-oks5-18-1, I can see 4 images only instead of 5. Missing one is ob-oks5-18-1_front.jpg
Similar thing are with other products.

I've tried to rename problem image. _front2 doesn't show; _fr or _fron so show. I supposed that problem may be due to length of the name, but in the other product _side shows, _rear (same length) - doesn't. I'm frustrated...

Any ideas why this may happen?
Thanks

7 Feb 2012, 3:25 PM
#10
webkat avatar

webkat

Zen Follower

Join Date:
Jan 2012
Location:
New England
Posts:
238
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

I thought it only looked for _01, _02, _03 etc at the end of filenames. How about renaming them

ob-oks5-18-all_1.jpg
ob-oks5-18-all_2.jpg
ob-oks5-18-all_3.jpg
ob-oks5-18-all_4.jpg

(assuming your main product image is ob-oks5-18.jpg)

True, you won't know by the filename which is front/rear/side, etc, but the software will know what to do with them.

7 Feb 2012, 3:43 PM
#11
rafcamera avatar

rafcamera

New Zenner

Join Date:
Mar 2006
Location:
Belarus
Posts:
63
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

Thanks, but this doesn't work either. I've renamed to _1 .. _5, and numbers _1, _2 and _5 show, but _3 and _4 doesn't. Weird situation...
May be someone know which exactly module is responsible for collecting additional images? I've installed many mods, so one of them causes error, probably.

7 Feb 2012, 4:23 PM
#12
rafcamera avatar

rafcamera

New Zenner

Join Date:
Mar 2006
Location:
Belarus
Posts:
63
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

Hm. More and more strange... It seems that Zen code itself works fine. When I've inserted 'echo $file' line into additional_images.php script where it reads out an image dir, it listed me about 1200 files instead of actual 1800+. As expected, there are _1, _2 and _5 in the list, but no _3 and _4. So, does this mean that I have problem with my hosting provider? Will search about this dir problem on the Internet meantime...

7 Feb 2012, 4:24 PM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Small, medium, large versions of product images--I've gotten mixed messages

I thought it only looked for _01, _02, _03 etc at the end of filenames. No, additional image filenames are not limited in any way to numbers. The one requirement (beside unique basenames) is that, when images are stored in subfolders like /images/mcl/, you must use an underscore _ to separate the basename and additional names. You have done this, so I don't see any impediment to proper function. I don't know why it wouldn't be working for you.

7 Feb 2012, 4:52 PM
#14
rafcamera avatar

rafcamera

New Zenner

Join Date:
Mar 2006
Location:
Belarus
Posts:
63
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

Solved!
For some reason
while ($file = $dir->read()) {
on the line 43 of additional_images.php soen't work.
It should be modified to while (($file = $dir->read()) !== false) {

I never reported bugs, so I don't know how to report it correctly, but I hope that developers read this post and take a look to decide if this is really worth correction. Works like a charm for me.

7 Feb 2012, 7:47 PM
#15
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Small, medium, large versions of product images--I've gotten mixed messages

The original code is functionally equivalent to

while (($file = $dir->read()) != false) {

so for some reason apparently you are experiencing $dir->read() evaluating to 0 or null unexpectedly, which is handled as "false". Your addition requires it to be explicitly "false", solving your problem.
It cannot be a common problem, though, or thousands of people would have experienced and presumably reported it. Could there be anything at all non-standard about how your site handles images?

7 Feb 2012, 8:05 PM
#16
rafcamera avatar

rafcamera

New Zenner

Join Date:
Mar 2006
Location:
Belarus
Posts:
63
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

I've found the answer. Here is what is written on http://www.php.net/manual/en/function.dir.php:
"Please note the fashion in which Directory::read()'s return value is checked in the example below. We are explicitly testing whether the return value is identical to (equal to and of the same type as - see Comparison Operators for more information) FALSE since otherwise, any directory entry whose name evaluates to FALSE will stop the loop. "

Exactly my case since I had '0' subfolder in the 'mcl' folder. So, the loop stopped after it got to read the '0' folder entry from the directory instance.
So, I'm sure that Zen code needs to be fixed now to prevent such rare (but possible, as you can see) cases.

7 Feb 2012, 8:14 PM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Small, medium, large versions of product images--I've gotten mixed messages

I see the main image:
/images/mcl/ob-oks5-18-1.jpg

I see the additional images:
/images/mcl/ob-oks5-18-1_all.jpg
/images/mcl/ob-oks5-18-1_fron.jpg
/images/mcl/ob-oks5-18-1_front.jpg
/images/mcl/ob-oks5-18-1_rear.jpg
/images/mcl/ob-oks5-18-1_side.jpg

Which one is missing? :unsure:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 Feb 2012, 8:15 PM
#18
rafcamera avatar

rafcamera

New Zenner

Join Date:
Mar 2006
Location:
Belarus
Posts:
63
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

Damn... There are 50 files in the Zen 1.5 distributive with directory handling. I suppose that each and every of them should be fixed. Will do this to my copy tomorrow.

Ajeh, nothing is missing now since I've fixed code checking return value of directory read for additional images. But there are 49 more php files that make wrong checks in other cases, and they need to be fixed as well to prevent problems if files or folders whose names evaluate to FALSE will be created somewhere (template '0', for example).

7 Feb 2012, 8:24 PM
#19
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Small, medium, large versions of product images--I've gotten mixed messages

I had '0' subfolder in the 'mcl' folder. This is critical information which you didn't tell us. Is this /0/ subfolder needed with that name?

Linda - the file edit in post #14 solved the problem, so all images now display. It is still puzzling because I would think the /mcl/ folder's content would be looked at sequentially and either all of one product's files would be processed before the 0 broke it, or the 0 would be processed first and you would not see any additional images. Maybe you can shed some light on MySQL/PHP processing in this area?

7 Feb 2012, 8:35 PM
#20
rafcamera avatar

rafcamera

New Zenner

Join Date:
Mar 2006
Location:
Belarus
Posts:
63
Plugin Contributions:
0

Re: Small, medium, large versions of product images--I've gotten mixed messages

gjh42:

This is critical information which you didn't tell us. Is this /0/ subfolder needed with that name?

How did I know that this is critical? I'm not a php pro. Just learning by experience. No need for such name for that folder (I just used to give simple names to temporary or 'to-process' folders - '0' puts it into beginning of the list to not forget about it).

Maybe you can shed some light on MySQL/PHP processing in this area?
I've read about this issue few hours ago. Directory reads not in alphabetical order. It is rather equivalent to 'unsorted' form of the list, with folders scattered in midst of files. I didn't notice that problem until I created '0' folder few months ago. And I've noticed first problems today only (though they appeared long ago, most probably, since it is impossible to tell how OS arranges files and folders in FAT or whatever linux uses).