This is driving me crazy.
I added a couple of images to my theme. They are on my theme_name/web/images folder.
The images are returning a 404.
I delete the folder pub/static/frontend/vendor/theme_name/en_US and on the first access they load. As soon as I try to load the images again they return 404 again.
The images are in the correct path.
Any ideas on what could be causing this? Permissions?
-
Which code have you written to call images?Prashant Valanda– Prashant Valanda2017年08月16日 15:55:22 +00:00Commented Aug 16, 2017 at 15:55
-
<?php echo $block->getViewFileUrl('images/selos/filename.svg'); ?> Any better solution?Cátia Rodrigues– Cátia Rodrigues2017年08月16日 16:05:46 +00:00Commented Aug 16, 2017 at 16:05
-
Can you please share your image URL which you are getting by above code?Abhishek Panchal– Abhishek Panchal2017年08月16日 18:47:44 +00:00Commented Aug 16, 2017 at 18:47
-
domain/pub/static/frontend/vendor/theme_name/en_US/images/selos/filename.svg I've tried with "Sign Static Files" set to yes and no. Both return the same result. Also tried replacing every svg file with png's. Nothing seems to workCátia Rodrigues– Cátia Rodrigues2017年08月16日 22:27:58 +00:00Commented Aug 16, 2017 at 22:27
3 Answers 3
Well, after days of looking into this problem I realised it had nothing to do with magento at all. Our designer was uploading the images trough Mega (client), and for some reason after I downloaded the images that problem occurred. After sending me the same images another the problem was solved.
I had the same case with facebook logo (svg). I assume the logo is in a compressed format. To fix the 404, I made a copy of the logo with inskape and replace the original image with the new file. After this process the image is four time bigger (600b for 2.2kb).
Call Media Images in PHTML Files
<img src="<?php echo $mediaUrl.'wysiwyg/demo.jpg'; ?>" />
Call Web Images in PHTML File
<img src="<?php echo $this->getViewFileUrl('images/demo.png'); ?>" />
Call Web Images in Static block and CMS page
<img src="{{view url="images/demo.jpg"}}" />
Call Media Images in Static block and CMS page
<img src="{{media url='wysiwyg/demo.png'}}; ?>" />