Buit of a strange one, but hopefully it’s easy to resolve.
I have uploaded some product Category images to certain category pages in the Admin client but when I view them on the web they don’t load. The reason appears to be that it is trying to load two paths in the src attribute, which are slightly different.
Any ideas what I need to do to resolve this… 🙂
src=”https://www.myurl.com/pub/media/catalog/category//pub/media/catalog/tmp/category/25mm.jpg“
As you can see there are two paths in the URL, one has “tmp” (in bold) and if I modify the SRC this one loads. It appears that it is prepending the URL?
Any ideas would be appreciated.
src=”/pub/media/catalog/tmp/category/25mm.jpg” <- This one loads the image?
2
Answers
Which version of magento 2 do you use?
I’ve had a similar problem with magento 2.3.4
When you save a category for which you just added an image. The model that handles the category images won’t move your image from the tmp folder to the pub/media/catalog/category (which should be the path to the image).
So you have to override to Image.php model from the catgeory to move the file from tmp after is saved.
Hope this will help you.
Since Magento 2.3.4 this problem occurs.
/vendor/magento/module-catalog/Model/Category/Attribute/Backend/Image.php
public function beforeSave($object)
In This method below code is creating issue
Update it with
This will fix issue
Do Not forget to override this file from your module to avoid direct core file changes
Github issue: https://github.com/magento/magento2/issues/28100