Magento Forum

   
/media/catalog/product/ folders - anyone understand how they work? 
 
golles
Sr. Member
 
Total Posts:  257
Joined:  2008-01-15
 

Hi There

Not sure if this is the most appropriate forum to post this to.

has anyone managed to get to grips with how the media/product and sub folders actually work.

We have some with capital letters some with lower case letters (for the folder names) both containing the same files. Lower case folder names contain image names that start in upper case and vice versa.

When we upload new images they go into one set of folders then appear to get moved to another. Sometimes into the lower case folder names sometimes into the upper case names.

it is just a bit of a mystery to how this actually works.

it would be good to know what the various folders are for and at what point images get moved around between folders

Thanks for the help

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

I guess it depends of what OS you are using.

Windows based systems don’t care about case.  So, if I upload Lee.jpeg and lee.jpeg, they are essentially the same filename.

When you upload a file via Magento, the Varien_File_Uploader class does all the work finding a home for a file.  You give it a base directory and list of valid extensions.  You can also set a flag to make is use ‘dispersion’.  When you tell it to use dispersion, it takes the first 2 letters of the filename and makes a directory structure.

So:
lee.jpeg -> /l/e/lee.jpeg
or
Bob.jpeg -> /B/o/Bob.jpeg

Well, on a UNIX system case matters.  So the directory /B/o is NOT the same as /b/o
Window doesn’t care about case.  /B/o === /b/o

Now to what is probably happening for you.

You are probably uploading mixed case files. 
The first file you upload is ‘lee.jpeg’, that becomes ‘/l/e/lee.jpeg’
The second file you upload is ‘LEland.jpeg’, that becomes ‘/l/e/LEland.jpeg’ in windows and ‘/L/E/LEland.jpeg’ in UNIX

The reason is that windows thinks /L/E === /l/e and says the directory already exists.  So, Magento uses /L/E/LEland.jpeg and windows saves it in /l/e/LEland.jpeg

Magento should probably lowercase every filename to cover edge cases between windows and UNIX to be honest.

Of course, I could be totally wrong and you should just ignore everything I just said in that case.  grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
golles
Sr. Member
 
Total Posts:  257
Joined:  2008-01-15
 

thanks we are on linux

Your explanation helps us a lot - thanks for that - but wer are seeing slightly different results from what you are stating:

i.e.
all of our images are lower case (it is part of our internal process for image preperation
we are seeing lower case image names in upper case folders and vice versa
images appear to move directories - e.g. move (or rather copied) from an upper case folder to a lower case one.

I could be wrong on the latter, but I am almost sure.

thanks again for taking the time to respond - much appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

Oh, sorry.  What I mentioned is an issue regardless, just not yours.  wink

Looking at the code, I cannot see why you would get weird casing like you explain.

Mage_Adminhtml_Catalog_Product_GalleryController::uploadAction() is where the magic should be.  But I see nothing,

Try searching for “Mage::getSingleton(’catalog/product_media_config’)” in the code.  You’ll find lots of interesting places to look.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top