Despite best efforts, I have images in cache that aren't loading, primarily because they are not present in the cache directory. I have tried clearing the media images cache. Short of deleting all contents of that directory or manually trying to import the images (which I would need to resize to the respective size before importing), I have tried everything to get the images stored in the cache directory. The images were previously loading, but aren't anymore. Does anyone have a solution?
Magento 1.9 – Cache Issue with Images Not Loading
cachemagento-1.9media-images
Related Solutions
If you don't have proper permissions on the var/
folders, Magento can write its cache information to the system /tmp
folder.
This can lead to a situation where you've changed the base URLs in the Magento database, cleared cache (manual deletion of all mage-?? folders in var/cache
), (cleared APC cache if you're running the op-code cache), (manually disabled the compiler (1.4.x.x and later)) and the system still looks for the original site.
Most people who own their own server discover that the site magically starts working after fixing, clearing and resetting permissions and then rebooting the server. The server reboot clears /tmp
of the Magento cache files and Magento finally starts looking at its own configuration to find where it's located.
If you have this happen, set your var/
folder permissions so that both the login user and web server process can access the var/
folder tree. Then if you have permissions to navigate over to the /tmp
folder, go delete the /tmp/magento
folder. Pay particular attention to permissions on the subfolders var/cache/
and var/tmp/
must be writable by the web server process which may be running as www-data
, nobody
, etc.
Screen shots of this in action...
The Magento directory found in /tmp
...
And the Cache living in that directory. Note the path -> /tmp/magento/var/cache
You need to set image sizes in view.xml
file inside your theme
Code would be like this:
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
<media>
<images module="Magento_Catalog">
<image id="bundled_product_customization_page" type="thumbnail">
<width>140</width>
<height>140</height>
</image>
<image id="cart_cross_sell_products" type="thumbnail">
<width>200</width>
<height>248</height>
</image>
<image id="cart_page_product_thumbnail" type="small_image">
<width>165</width>
<height>165</height>
</image>
........
</images>
</media>
......
</view>
Make sure your all images sizes are 1:1 ratio, as your main image proportion is 1:1 in ratio, than after frontend deployment it should work
php bin/magento setup:static-content:deploy -f
Best Answer
There are many things that could be causing this issue, Please look into few things:
On the Product Information page in your admin backend, under 'Images', make sure the radio buttons have an image selected for 'Base Image', 'Small Image', 'Thumbnail', and that they aren't 'Excluded'.
Make sure the /media directory is in your Apache web server's group (usually 'www-data' or 'httpd'). Magento also needs to be able to write to this directory, so you can run this command to set those permissions:
sudo chmod -R 775 /path/to/magento/media
In System->Configuration->General->Web, make sure "Base Media URL" is correct under both "Secure" and "Unsecure.
If this answer is useful Please mark it as solution thanks.