Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a wysiwyg custom attribute.

Insert an image there: enter image description here

But in the html code source I see this one:

<img src="{{media url="wysiwyg/article1.jpg"}}" alt="" />

Instead of

<img src="imagepath/article1.jpg" alt="" />

This html source is generated by this code:

<?php echo $_item->getPreview() ?>

Why wysiwyg cms directive was not replaced with image url?

share|improve this question
What do you mean 'in a correct way'? – oleksii.svarychevskyi Feb 16 '14 at 17:04
To get <img src="imagepath/article1.jpg" /> instead of {{media...}}. – Anthony Feb 16 '14 at 17:23
That is how magento wysiwyg works. During output '{{media url="wysiwyg/article1.jpg"}}' will be changed to 'imagepath/article1.jpg'. So what is your exact problem? – oleksii.svarychevskyi Feb 16 '14 at 18:03
It doesn't change it) – Anthony Feb 16 '14 at 18:14
Can you please update the question with code of form field definition? – oleksii.svarychevskyi Feb 16 '14 at 18:15
up vote 5 down vote accepted

Custom attribute with wysiwyg cannot be simply outputted.

If it contains cms directives {{media url="wysiwyg/images_2_.jpg"}}, it should be preprocessed with catalog/output helper.

    $product = $this->getProduct();
    $attribute = $product->getYourAttribute();
    $attributeName = 'your_attribute_name';
    echo $this->helper('catalog/output')->productAttribute($product, $attribute, $attributeName);


Check that in sql upgrade your custom attribute was created correctly with all necessary properties

$this->addAttribute('catalog_category', 'custom_attribute', array(
    'group'                    => 'General',
    'input'                    => 'textarea',
    'type'                     => 'text',
    'label'                    => 'Custom attribute',
    'backend'                  => '',
    'visible'                  => true,
    'required'                 => false,
    'visible_on_front'         => true,
    'global'                   => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'wysiwyg_enabled'          => true,
    //these attribute is very important for processing cms directives
    'is_html_allowed_on_front' => true,

Also make sure that "Allow Dynamic Media URLs in Products and Categories" in System->Configuration->Catalog->Frontend is set to "yes".

share|improve this answer
Yes, you are right. I didn't write that attribute is like cms page attribute. It's not for catalog entity. So I found an answer: <?php $helper = Mage::helper('cms'); $processor = $helper->getPageTemplateProcessor(); $html = $processor->filter($_item->getPreview()); ?> – Anthony Feb 16 '14 at 20:49
If my answer helped you mark it as accepted. – oleksii.svarychevskyi Feb 16 '14 at 20:53

Use helper class

Instead of <?php echo $_product->getDescription();?>,

use <?php echo $_helper->productAttribute($_product, nl2br($_product->getDescription()), 'description'); ?>.

For me, its solved same issue on magento version 1.8.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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