0

I have an image stored in media/images. I have a .phtml file that includes the following code:

<tr>
  <td><img src="{{media url='images/Bocadillos.png'}}" width="30" height="30"></td>
</tr>

but the image is not loading. I also tried

img src ="media/images/Bocadillos.png"

but it's also not working.

Which is the correct way to reference an image here?

0

I'm pretty sure the {{...}} is a cms directive only used in cms/pages and cms/blocks.

If you are looking to add a specific media file to a template try:

<?php echo $this->getUrl('pub/media') . 'path/to/url.png'; ?>

| improve this answer | |
0

Use below code,

<image src='<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'images/YOUR_IMAGE_NAME'; ?>' />
| improve this answer | |
0

You can use getBaseUrl function of Mage class to get Media URL in template file.

<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'images/Bocadillos.png'; ?>

Please check this for more details.

| improve this answer | |
0

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) - will return http://[yourdomain].com/media/.

So you can use it like this:

<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>images/Bocadillos.png" />
| 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.