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();
  • may i know in which file i need to use the above code? – jafar pinjar Jun 10 at 7:47
  • @jafarpinjar you can inject \Magento\Catalog\Api\ProductRepositoryInterface and get product collection,then use the above code arbitrarily. – tokey Jun 10 at 7:55

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.