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

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

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?

4 Answers 4


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'; ?>


Use below code,

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

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.


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" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.