0

I'm trying to add an image from my theme in template like

<img src="<?php echo $this->getViewFileUrl('Vendor_Theme::images/image.svg'); ?>" />

But this url adds en_us. How can I remove it?

1

It is normal behavior.

During deployment static content all files from directories like Vendor/Module/view/frontend/web will be copied to [MAGENTO_ROOT]/pub/static/.....

After that static content will be available for loading by client side (your browser for example).

  • How do I fix it? Cause now image can't be found because of that. – Robot__4 Oct 9 '17 at 7:19
  • try to rerun static content deploy – Max Oct 9 '17 at 7:50
  • I've done it a few times, but nothing changes. I also tried <img src="{{images/image.svg}}" />, but it also doesn't work. I'm trying to show an image that is in the theme. I'm rewriting one template (I'm doing it in the theme itself). – Robot__4 Oct 9 '17 at 8:00
  • for example app/code/Magento/Captcha/view/adminhtml/templates/default.phtml contains code <?= $block->escapeUrl($block->getViewFileUrl('Magento_Captcha::reload.png')) ?> and look like works. try to validate your image location according example – Max Oct 9 '17 at 8:03
  • I just needed to remove Vendor_Theme and it started to work. Thanks. – Robot__4 Oct 9 '17 at 8:12

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.