2

I have issue in product images.

Right now products are loading from cache from the path like below.

  site_url/media/catalog/product/cache/2765542505660baab28ecd555e27366e/t/m/image_name.jpg

This is leading to 404 error page.

But if we remove cache from the image url, the image is loading successfully.

like below one

 site_url/media/catalog/product/t/m/image_name.jpg

This will load the image correctly,

So I am planning to change the image url like this in all the pages.

How can load the image without cache path in product list page and in detail pages.

Can anyone look into this and update me ideas.

Thanks in advance!!

1

you shoud have product collection.

// return array, you can choose what you want
$image = $product->getMediaGalleryImages();
| improve this answer | |
  • may i know in which file i need to use the above code? – jafar pinjar Jun 10 '19 at 7:47
  • @jafarpinjar you can inject \Magento\Catalog\Api\ProductRepositoryInterface and get product collection,then use the above code arbitrarily. – tokey Jun 10 '19 at 7:55
  • I need to make this change in all the pages wherever the products are loading – jafar pinjar Jan 10 at 9:43
0

You should try using the image resize command to re-generate images for valid cache path.

php bin/magento catalog:image:resize

| improve this answer | |

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.