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

Images not showing in Windows installation
 
redpen
Sr. Member
 
Total Posts:  254
Joined:  2008-01-23
 

Just updated to the latest version this morning, and the product image paths now appear to be:

http://10.0.0.20/magento/media/C:\xampp\htdocs\magento\media\catalog\product/cache/1/image//t/3\-PRODUCTNAME-.jpg

Which obviously isn’t going to work (-PRODUCT NAME-; added by me).  They worked fine on the last version.  Any ideas guys, please? 

Windows installation, via XAMPP.  Tried the fix in the Wiki, but it’s obviously outdated.  Local IP is fine, path is fine (until the obvious bit).  Images are being stored in the correct path, it’s just not finding the path in both the admin and the front end to display the pics.

 
Magento Community Magento Community
Magento Community
Magento Community
 
redpen
Sr. Member
 
Total Posts:  254
Joined:  2008-01-23
 

OK, hacking the database directly via PHPMyAdmin fixes the \ rather than /, so at least the thumbnails now show up in the admin back-end, but still no joy with the front end.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Core
Member
 
Total Posts:  68
Joined:  2008-03-09
 

Same issue here.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Core
Member
 
Total Posts:  68
Joined:  2008-03-09
 

Fix is in \magento\app\code\core\Mage\Catalog\Model\Product\Image.php

getURL function around line 282
There is a forward slash instead of a backslash in the replace + there are all the backslashes in the path name (like in the DB as you saw)
Not sure if this is a very good fix but to get it working:

Change

public function getUrl()
    
{
        $baseDir 
Mage::getBaseDir('media');        
        
$path str_replace("{$baseDir}/"""$this->_newFile);        
        return 
Mage::getBaseUrl('media') . $path;
    
}

to

public function getUrl()
    
{
        $baseDir 
Mage::getBaseDir('media');        
        
$path str_replace("{$baseDir}\\"""$this->_newFile);        
        
$path str_replace("\\","/",$path);         
        return 
Mage::getBaseUrl('media') . $path;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
redpen
Sr. Member
 
Total Posts:  254
Joined:  2008-01-23
 

That fixed it, thank you SO much.

=)

 
Magento Community Magento Community
Magento Community
Magento Community
 
itcrowd.asia
Jr. Member
 
Total Posts:  13
Joined:  2008-03-08
 

Question to Magento. Why do you not use a directory seperator constant for stuff like this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
vtching
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2008-03-23
 

Had the same issues too.

The fix is cool, but i still had the problem in the backend.
I made a change in app\code\core\Mage\Catalog\Model\Product\Attribute\Backend\Media.php, around line 85,

foreach ($value['images'as &$image{
    
if(!empty($image['removed'])) {
        $clearImages[] 
$image['file'];
    
else if (!isset($image['value_id'])) {
        $newFile                   
$this->_moveImageFromTmp($image['file']);
        
$newImages[$image['file']] $newFile;
        
$image['file']             $newFile;
    
}
}
to

foreach ($value['images'as &$image{
    
if(!empty($image['removed'])) {
        $clearImages[] 
$image['file'];
    
else if (!isset($image['value_id'])) {
        $newFile                   
$this->_moveImageFromTmp($image['file']);
        
$newFile                   str_replace("\\""/"$newFile); // Replace backslashes
        
$newImages[$image['file']] $newFile;
        
$image['file']             $newFile;
    
}
}
so that the name saved in the database always contains slashes.

This done, i still had problems to have images showing up in the frontend, because it was displaying the “No image for this product”.
My problem was that PHP memory limit was disabled (not in phpinfo - looks like PHP versions older than 5.2.1 under windows have memory_limit disabled),
so i made another little change to have this work.
Don’t know if it’s the best workaround, but fixed my problem:
In app\code\core\Mage\Catalog\Model\Product\Image.php, around line 95:

protected function _getMemoryLimit()
{
    $memoryLimit 
ini_get('memory_limit');

    
// Added these 2 lines
    
if ($memoryLimit == "")
        
$memoryLimit "16M"// Or whatever value
                        
    
if (substr($memoryLimit, -1) == 'M'{
        
return (int)$memoryLimit 1024 1024;
    
}
    
return $memoryLimit;
}
Anyway, the best thing to do is to update PHP version, i guess.
 
Magento Community Magento Community
Magento Community
Magento Community
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

I get some issue your code doesn’t resolve… Can’t find how to pass trought it ... :(

Warning: Invalid argument supplied for foreach() in /var/www/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php on line 82
[0] in Mage_Catalog_Model_Product_Attribute_Backend_Media->beforeSave(Mage_Catalog_Model_Product)
[1] in call_user_func_array(Array[2], Array[1]) in /var/www/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 494
[2] in Mage_Eav_Model_Entity_Abstract->walkAttributes("backend/beforeSave", Array[1]) in /var/www/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 1133
[3] in Mage_Eav_Model_Entity_Abstract->_beforeSave(Mage_Catalog_Model_Product) in /var/www/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product.php on line 104
[4] in Mage_Catalog_Model_Resource_Eav_Mysql4_Product->_beforeSave(Mage_Catalog_Model_Product) in /var/www/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 801
[5] in Mage_Eav_Model_Entity_Abstract->save(Mage_Catalog_Model_Product) in /var/www/app/code/core/Mage/Core/Model/Abstract.php on line 234
[6] in Mage_Core_Model_Abstract->save() in /var/www/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php on line 323
[7] in Mage_Adminhtml_Catalog_ProductController->saveAction() in /var/www/app/code/core/Mage/Core/Controller/Varien/Action.php on line 341
[8] in Mage_Core_Controller_Varien_Action->dispatch("save") in /var/www/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 141
[9] in Mage_Core_Controller_Varien_Router_Admin->match(Mage_Core_Controller_Request_Http) in /var/www/app/code/core/Mage/Core/Controller/Varien/Front.php on line 147
[10] in Mage_Core_Controller_Varien_Front->dispatch() in /var/www/app/Mage.php on line 424
[11] in Mage::run("default") in /var/www/index.php on line 40

Regards,
Antoine

 
Magento Community Magento Community
Magento Community
Magento Community
 
doctorlogos
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-05-06
 

Dear Community,

I have the same issue:

- Windows Local installation via XAMPP.
- Sample data working.
- Clean final installation. All OK.

But I can´t see the images neither front or backend.

What shall I do?
I coudn´t find a clear answer within the forum…

Thanks!

SOLVED: I copied the content in a wrong path: magento/media/media/catalog

Obviously, the rigth path is magento/media/catalog

Alsod I changed the permissions of these directories (rigth click/properties, uncheck ‘read only’)

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lukasz 'Severiaan' Grela
Jr. Member
 
Total Posts:  19
Joined:  2010-04-05
Southampton
 

Hi All,
this is my first post:)

I have the same issues, images were not seen in front end nor back end, firebug was showing the Internal Server Error, adding

SecFilterEngine Off
SecFilterScanPOST Off

to the .htaccess in media folder didn\’t worked but removing this file helped, now it was there with purpose so my question is: did I made something unsecure by doing that or it will eventually stop magento working?

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
federicosoich
Jr. Member
 
Total Posts:  2
Joined:  2009-04-25
Mar del Plata
 

THANKS Lukasz ‘Severiaan’ Grela remove the .htacces WORKS FOR ME !

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