0

I have a magento store with version 1.9 hosted on http://bandsawblades.co.uk

which I move to 1and1 server on a subdomain called

http://test.bandsawbladedirect.co.uk

The images are not showing on the home page on the new server but the images are there in the media folder. For example if you take the following featured product

http://test.bandsawbladedirect.co.uk/index.php/featured-products/mps-3742-bi-metal-air-saw-blade-with-1-2-mm-cutting-depth-and-ober-pneutec-chikago-pneumatic-shank.html

The images are there at

http://test.bandsawbladedirect.co.uk/media/product/7c6/morse-hef-band-saw-blades-1385-mm-54-1-2-long-various-widths-and-tpi-morse-hef-band-saw-blades-1385-mm-54-1-2-long-a4a.jpg

Which I derived from this page

http://bandsawblades.co.uk/index.php/featured-products/mps-3742-bi-metal-air-saw-blade-with-1-2-mm-cutting-depth-and-ober-pneutec-chikago-pneumatic-shank.html

I have set the media folder permission to 777, cleared var folder and set the permission to 777 there too but no luck. Can anyone help me on this?

1

I figured it myself. I had to solve 2 along the migration process which I wish to share here.

As the source server is a Linux box, it supports case-sensitive folder structure. Hence I had both the lower case and upper case directories with the same name in the server. For example, we have images in both media/products/F and media/products/f directories. As the source server had many GBs worth images, I couldn't compress them into a single zip folder before downloading it to the destination server. Hence I downloaded the images using FileZilla to my Windows machine and then uploaded them to the destination server.

As Windows doesn't permit to create the same directory name with a different case, it treated both /media/catalog/product/F and /media/catalog/product/f as /media/catalog/product/F. Hence I was missing /media/catalog/product/f directory on the destination server, which resulted in some products showing images (i.e. the ones which are linked to /media/catalog/product/F) and the others are missing images (i.e. the ones which are linked to /media/catalog/product/f)

The second issue was related to the memory_limit setting. Magento is using GD library for thumbnail creation. The PHP class used to generate thumbnails stays at Varen/Gd2.php file. The following method in that file has a flaw which I have described below

protected function _convertToByte($memoryValue)
{
    //file_put_contents(dirname(__FILE__)."/memorylimit.txt",$memoryValue);

    if (stripos($memoryValue, 'M') !== false) {
        return (int)$memoryValue * 1024 * 1024;
    } elseif (stripos($memoryValue, 'KB') !== false) {
        return (int)$memoryValue * 1024;
    }
    return (int)$memoryValue;
}

As you can see the function doesn't check for Gigabyte Memory limit (GBs) or unlimited memory (-1). Unfortunately, my destination server had an unlimited memory limit (-1). This function returns -1 which reduces to no memory at all. Hence the thumbnail images failed to generate. I made a patch here to return 2GB memory by default and the memory issue has disappeared.

protected function _convertToByte($memoryValue)
{
    //file_put_contents(dirname(__FILE__)."/memorylimit.txt",$memoryValue);

    if (stripos($memoryValue, 'M') !== false) {
        return (int)$memoryValue * 1024 * 1024;
    } elseif (stripos($memoryValue, 'KB') !== false) {
        return (int)$memoryValue * 1024;
    }
    /*return (int)$memoryValue;*/
    return 2147483648;      //1024*1024*1024*2 = 2G

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.