Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Missing Images
 
kimchi209
Member
 
Total Posts:  67
Joined:  2008-12-22
 

Since the 1.3 upgrade I have seemed to work out all the kinks I have experienced so far except for images. Even though I backed up and re-uploaded the media folder still half of my items are showing without pictures even though they were there before the upgrade. Uploading new images through the backend seems to work, but not feasible for a store of 4,000 products with half missing images.

I also tried clearing image cache through System:Cache Management to no avail.

THANKS!

 
Magento Community Magento Community
Magento Community
Magento Community
 
impact
Jr. Member
 
Total Posts:  12
Joined:  2009-01-23
 

Please check the uploaded mediafolders (I think the product folder will have the problems)

It might be that for example a folder a and A exist.
Maybe your FTP client failed to upload a or A, because it isn’t case sensitive.

Could you let me know if this helps?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Chris Jones
Jr. Member
 
Total Posts:  9
Joined:  2009-02-11
 

I’m having similar problems only in my case it’s when moving from one server to another. On the new server I started with a clean install, imported my database info, and copied the media and theme folders. Some images appears, most do not. Any help on this would be appreciated.

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

when you download or backup you media folder via ftp to a windows based pc it treats lowercase and uppercase folder names as the same thing so in media/catalog/product/a is essentially the same as media/catalog/product/A (whereas on linux based file systems they are treated differently)

therefore as you download folders they are overwritten giving you only one directory where there is a possiblility that 2 exist e.g. a and A

workaround

copy all of the lowercase folders to one backup directory on your pc and the upper case to another folder

took us a good while to figure this one out but never had issues with images backup since.

(the overwrite on a windows PC also happens if you backup via an archive file (e.g. cpanel backup) and then unzip that locally on a windows PC)

Hope this helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Chris Jones
Jr. Member
 
Total Posts:  9
Joined:  2009-02-11
 

I just found a part of the problem. I’m developing under OS X. It use HFS+ which by default is case insensitive. When moving it to my staging server, it is probably ext3 so then it becomes case sensitive. For one of my products, the full size image set as capital S where as the thumbnail and small image is set to lowercase s.

So, what I need to figure out is how did it get this way in the first place, how do I keep it from happening again, and how do I fix the current pickle that I’m in?

My thought right now is to just go through the catalog_product_entity_media_gallery table start updating it manually (after I make a backup of course).

Any thoughts? Has this been an issue before?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Chris Jones
Jr. Member
 
Total Posts:  9
Joined:  2009-02-11
 

I fixed the issue. It definitely is the “A” vs “a” folder thing. Here’s the full issue, the short term fix, and the long term fix.

The issue, like I stated before is uploading product images on a case insensitive file system. If you have two files, Test.jpg and test.jpg, on a case sensitive file system Magento will store Test.jpg to T/e/Test.jpg and test.jpg to t/e/test.jpg. On a case insensitive file system, it depends on which one you upload first. If you upload Test.jpg first with will create the path T/e/ and then store test.jpg in the same folder as it can’t have one folder named T and another named t. This is just sloppy.

Here’s the short term fix. Back up your Magento database and your /media/catalog/product folder. Then write a file called fixcatalog.php and enter the following code replacing “/yourmagentoinstall/media/catalog/product”, “mysql_host”, “mysql_user”, “mysq_password”, “mysql_db” with your information.

<?php

fix_magento_catalog
("/yourmagentoinstall/media/catalog/product""mysql_host""mysql_user""mysq_password""mysql_db");

function 
list_files_and_folders($path=".")
{
    $files 
= array();
    if (
is_dir($path))
    
{
        $fh 
opendir($path);
        while ((
$file readdir($fh)) !== false)
        
{
            
if (strcmp($file".")==|| strcmp($file"..")==0) continue;
            
$filepath $path "/" $file;
            if ( 
is_dir($filepath) )
            
{
                array_push
($files$filepath);
                
$files array_merge($fileslist_files_and_folders($filepath));
            
}
            
else
            
{
                array_push
($files$filepath);
            
}
        }
        closedir
($fh);
    
}
    
else
    
{
        $files 
false;
    
}
    
return $files;
}

function fix_magento_catalog($path$mysql_host$mysql_username$mysql_password$mysql_db)
{
    $files 
list_files_and_folders($path);
    foreach (
$files as $val)
    
{
        
echo "Converting {$val} to".strtolower($val)." \n";
        
rename($valstrtolower($val));
    
}
    
    $conn 
mysql_connect($mysql_host,$mysql_username,$mysql_password);
    
mysql_select_db($mysql_db);

    
$query mysql_query("select value_id, value from catalog_product_entity_media_gallery") or die(mysql_error());

    while(
$result mysql_fetch_assoc($query)) {
        
echo "Converting database value {$result['value_id']} to ".strtolower($result['value'])." \n";
        
mysql_query("update catalog_product_entity_media_gallery set value='".strtolower($result['value'])."' where value_id='{$result['value_id']}'") or die(mysql_error());
    
}
}
?>

Then run “php fixcatalog.php” from a terminal or place the file in your webserver root and access in a browser. That will change all the product image paths in the database to lowercase as well as the file names in your /media/catalog/product folder. Then remove /media/catalog/product/cache and be sure your permissions on your media folder are set correctly “chmod -R o+w media”. That should fix it. Keep that file handy if the problem arrises again.

Long term solution. This badly needs to be fixed in the next release. A proposed solution has already been written by someone else.

I hope this helps someone else. Thanks again for the replies. That got me started in the right direction.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Chris Jones
Jr. Member
 
Total Posts:  9
Joined:  2009-02-11
 

I should add that that should only be run on the machine with the case insensitive file system.

 
Magento Community Magento Community
Magento Community
Magento Community
 
eiocreative
Jr. Member
 
Total Posts:  21
Joined:  2009-01-24
 

Thank Chris for the code. It solved most of the issue for me.

However the references that Magento uses to what image it should use for base, small and thumb were still using various different cases.

I had to run a second script

function fix_magento_catalog($path, $mysql_host, $mysql_username, $mysql_password, $mysql_db)
{
$conn = mysql_connect($mysql_host,$mysql_username,$mysql_password);
mysql_select_db($mysql_db);

$query = mysql_query("select value_id, attribute_id, value from catalog_product_entity_varchar WHERE attribute_id = ‘70’ OR attribute_id = ‘71’ OR attribute_id = ‘72’") or die(mysql_error());

while($result = mysql_fetch_assoc($query)) {
echo “Converting database value {$result[’value_id’]} to “.strtolower($result[’value’]).’-’.$result[’attribute_id’]."<BR>";
mysql_query("update catalog_product_entity_varchar set value=‘“.strtolower($result[’value’]).”’ where value_id=’{$result[’value_id’]}’") or die(mysql_error());
}
}

This parses over all the links to what image is selected to be used by default and changes the case to lowercase to match the adjusted files.

Hope this helps someone else

James

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vyndrox
Jr. Member
 
Total Posts:  4
Joined:  2009-10-01
 

I’ve tried you’re code:

function fix_magento_catalog($path$mysql_host$mysql_username$mysql_password$mysql_db)
{
$conn 
mysql_connect($mysql_host,$mysql_username,$mysql_password);
mysql_select_db($mysql_db);

$query mysql_query("select value_id, attribute_id, value from catalog_product_entity_varchar WHERE attribute_id = â€˜70’ OR attribute_id = â€˜71’ OR attribute_id = â€˜72’") or die(mysql_error());

while(
$result mysql_fetch_assoc($query)) {
echo â€œConverting database value {$result[’value_id’]} to â€œ.strtolower($result[’value’]).’-’.$result[’attribute_id’]."<BR>";
mysql_query("update catalog_product_entity_varchar set value=‘“.strtolower($result[’value’]).”’ where value_id=’{$result[’value_id’]}’") or die(mysql_error());
}
}

But it get stuck at;

echo â€œConverting database value {$result[’value_id’]} to â€œ.strtolower($result[’value’]).’-’.$result[’attribute_id’]."<BR>";

With the following error msg:
Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /opt/lampp/htdocs/magentotest/fixcatalog.php on line 61

Anyone an idea how to fix this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
s4_optics
Member
 
Total Posts:  56
Joined:  2008-05-14
 

When we download the media directory the sub directory names change from lowercase to uppercase. How do I fix this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
All About Doors and Windows
Member
 
Avatar
Total Posts:  51
Joined:  2008-10-13
Kansas City, MO USA
 

Just ran into this issue. What I did is zip my local folder which had all the uppercase characters as a backup. then I made all the uppercase folders lowercase, tarred it, uploaded it and extracted it. We had a sync process setup that deleted all the remote files since they did not exist in local.

 
Magento Community Magento Community
Magento Community
Magento Community
 
brood22
Jr. Member
 
Total Posts:  1
Joined:  2010-05-07
 

Dear Magento pro’s!

I have performed an upgrade from Magento 1.3.2.3 to 1.4.1.0 three times now and still the product images are gone in the upgraded version.

First I read about a thread that said that when downloading the product images to a windows PC the index structure may get lost, so the images were first compressed into a .tar.gz and then downloaded directly to the new server where the upgrade took place.

After first restoring the old website on the new server: everything worked fine and all product images were showing.

Then I unpacked the zip of version 1.4.1.0 into the root directory of the website and initiated the upgrade by visiting the website.

I then fixed all bugs related to the upgrade, such as template errors and caching errors, and then initiated the new indexer via shell using the command.

php /var/www/vhosts/.../httpdocs/shell/indexer.php reindexall
After these actions the website worked again using the new version of Magento but all product images are 404.

What should I do to recover the product images? The images are still available in /media/ but not on the location that Magento tries to load them from.

All permissions are right, the /media/ directory is 777.

Best Regards,

Tom

 
Magento Community Magento Community
Magento Community
Magento Community
 
rainmist
Jr. Member
 
Total Posts:  14
Joined:  2009-10-06
 
Chris Jones - 17 April 2009 07:45 AM

I fixed the issue. It definitely is the “A” vs “a” folder thing. Here’s the full issue, the short term fix, and the long term fix.

The issue, like I stated before is uploading product images on a case insensitive file system. If you have two files, Test.jpg and test.jpg, on a case sensitive file system Magento will store Test.jpg to T/e/Test.jpg and test.jpg to t/e/test.jpg. On a case insensitive file system, it depends on which one you upload first. If you upload Test.jpg first with will create the path T/e/ and then store test.jpg in the same folder as it can’t have one folder named T and another named t. This is just sloppy.

Here’s the short term fix. Back up your Magento database and your /media/catalog/product folder. Then write a file called fixcatalog.php and enter the following code replacing “/yourmagentoinstall/media/catalog/product”, “mysql_host”, “mysql_user”, “mysq_password”, “mysql_db” with your information.

<?php

fix_magento_catalog
("/yourmagentoinstall/media/catalog/product""mysql_host""mysql_user""mysq_password""mysql_db");

function 
list_files_and_folders($path=".")
{
    $files 
= array();
    if (
is_dir($path))
    
{
        $fh 
opendir($path);
        while ((
$file readdir($fh)) !== false)
        
{
            
if (strcmp($file".")==|| strcmp($file"..")==0) continue;
            
$filepath $path "/" $file;
            if ( 
is_dir($filepath) )
            
{
                array_push
($files$filepath);
                
$files array_merge($fileslist_files_and_folders($filepath));
            
}
            
else
            
{
                array_push
($files$filepath);
            
}
        }
        closedir
($fh);
    
}
    
else
    
{
        $files 
false;
    
}
    
return $files;
}

function fix_magento_catalog($path$mysql_host$mysql_username$mysql_password$mysql_db)
{
    $files 
list_files_and_folders($path);
    foreach (
$files as $val)
    
{
        
echo "Converting {$val} to".strtolower($val)." \n";
        
rename($valstrtolower($val));
    
}
    
    $conn 
mysql_connect($mysql_host,$mysql_username,$mysql_password);
    
mysql_select_db($mysql_db);

    
$query mysql_query("select value_id, value from catalog_product_entity_media_gallery") or die(mysql_error());

    while(
$result mysql_fetch_assoc($query)) {
        
echo "Converting database value {$result['value_id']} to ".strtolower($result['value'])." \n";
        
mysql_query("update catalog_product_entity_media_gallery set value='".strtolower($result['value'])."' where value_id='{$result['value_id']}'") or die(mysql_error());
    
}
}
?>

Then run “php fixcatalog.php” from a terminal or place the file in your webserver root and access in a browser. That will change all the product image paths in the database to lowercase as well as the file names in your /media/catalog/product folder. Then remove /media/catalog/product/cache and be sure your permissions on your media folder are set correctly “chmod -R o+w media”. That should fix it. Keep that file handy if the problem arrises again.

Long term solution. This badly needs to be fixed in the next release. A proposed solution has already been written by someone else.

I hope this helps someone else. Thanks again for the replies. That got me started in the right direction.

Hello Chris,

Thank you for your great job. It saved lots of time.

Best Regards,

 
Magento Community Magento Community
Magento Community
Magento Community
 
NETRONIANinc
Member
 
Avatar
Total Posts:  57
Joined:  2010-05-28
 

here is where you can find the solution.
I can not copy paste it here because of magento’s policies
http://www.magentocommerce.com/boards/viewthread/32356/P15/

 
Magento Community Magento Community
Magento Community
Magento Community
 
MarcMa
Jr. Member
 
Total Posts:  1
Joined:  2013-05-15
 

grin So many guys discussed here, Really Great, Learned a lot.


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

better lighting,better life.High quality led lights,China leading led lights manufacturer and supplier.

 
Magento Community Magento Community
Magento Community
Magento Community
 
allanravn
Jr. Member
 
Total Posts:  1
Joined:  2013-04-24
 
eiocreative - 12 June 2009 02:58 AM

Thank Chris for the code. It solved most of the issue for me.

However the references that Magento uses to what image it should use for base, small and thumb were still using various different cases.

I had to run a second script

function fix_magento_catalog($path, $mysql_host, $mysql_username, $mysql_password, $mysql_db)
{
$conn = mysql_connect($mysql_host,$mysql_username,$mysql_password);
mysql_select_db($mysql_db);

$query = mysql_query("select value_id, attribute_id, value from catalog_product_entity_varchar WHERE attribute_id = ‘70’ OR attribute_id = ‘71’ OR attribute_id = ‘72’") or die(mysql_error());

while($result = mysql_fetch_assoc($query)) {
echo “Converting database value {$result[’value_id’]} to “.strtolower($result[’value’]).’-’.$result[’attribute_id’]."<BR>";
mysql_query("update catalog_product_entity_varchar set value=‘“.strtolower($result[’value’]).”’ where value_id=’{$result[’value_id’]}’") or die(mysql_error());
}
}

This parses over all the links to what image is selected to be used by default and changes the case to lowercase to match the adjusted files.

Hope this helps someone else

James

Thx James ... on 1.7.0.3 I had to use other attribute id’s ... this script worked as a second step for me correcting the base/small/thumb references ...

function fix_magento_catalog2($path$mysql_host$mysql_username$mysql_password$mysql_db

    $conn 
mysql_connect($mysql_host,$mysql_username,$mysql_password); 
    
mysql_select_db($mysql_db);

    
$query mysql_query("select value_id, attribute_id, value from catalog_product_entity_varchar WHERE attribute_id = '85' OR attribute_id = '86' OR attribute_id = '87'") or die(mysql_error());

    while(
$result mysql_fetch_assoc($query)) 
        
echo "Converting database value {$result['value_id']} to ".strtolower($result['value']).'-'.$result['attribute_id']."<BR>"
        
mysql_query("update catalog_product_entity_varchar set value='".strtolower($result['value'])."' where value_id='{$result['value_id']}'") or die(mysql_error()); 
    

}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2