0

To call the image from my media/img folder & display it in my list page I have used the below code:

 <?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."/img/".trim($value).".png'/>"; ?>

Now I want to call the image from my media/wysiwyg folder.

Is there any other way to call image from there apart from above mentioned code? Someone guide me please.

0

5 Answers 5

1
<?php echo "<img src='".Mage::getBaseUrl('media').trim($value).".png'/>"; ?>
3
  • The images are getting broken.
    – Ramya
    May 10, 2016 at 5:43
  • just check images exists at that path May 10, 2016 at 5:44
  • Ya the images are inside wysiwyg of media.
    – Ramya
    May 10, 2016 at 5:47
1

Replace this:

<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."/img/".trim($value).".png'/>"; ?>

With:

<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."/".trim($value).".png'/>"; ?>
1
<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."/".trim($value).".png'/>"; ?>

Updated

<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."/wysiwyg/ ".trim($value).".png'/>"; ?>
4
  • I tried that. The images are getting broken.
    – Ramya
    May 10, 2016 at 5:40
  • if your image is inside wysiwyg then you have to place a wysiwyg in place of img please check the updated answer. May 10, 2016 at 5:59
  • Is there any other way to call the image. By means of creating variable?
    – Ramya
    May 10, 2016 at 6:01
  • what do you mean creating variable please explain. May 10, 2016 at 6:02
1

Change it from

<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."/img/".trim($value).".png'/>"; ?>

to

<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."wysiwyg/".trim($value).".png'/>"; ?>
2
  • What do you mean by original? I just need to call the image inside my media/wysiwyg folder for the attribute craeted.
    – Ramya
    May 10, 2016 at 5:57
  • I have updated the anser plz check
    – Arunendra
    May 10, 2016 at 6:06
1

Use this code for media url :

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

This will return path to media directory, like : http://magento.demo/media/

Now you can append some STATIC things, like /img/ OR /wysiwyg/ as per your requirement (where the image resides).

Final step: Now append the name of your image file,

if image name is like abc.png then use :

<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."/img/".trim($value)."'/>"; ?>

if image name is like abc then use :

<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."/img/".trim($value).".png'/>"; ?>

Note: Replace /img/ as per your requirement

Your Answer

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

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