2

I'm having some problems within the product description as my client wants to use the wysiwyg-editor and its image upload features. Sadly all inserted image variables won't get parsed correctly so the output is something like this:

<img src="{{media url="someurl"}}">

which is in fact the same as the raw input.

Any suggestions how to fix this? I obviously don't want to change all image links to something hardcoded even if my client has just around 100 products ;)

(Magento 1.7.0.2)

5 Answers 5

7

I found the solution to my problem:

most themes like the one my client is using use this syntax to get the product description (containing wysiwyg codes):

echo $_product->getDescription(); 

but instead you have to use this not intuitive construction:

echo $this->helper('catalog/output')->productAttribute($_product, $_product->getDescription(), 'description');

which then does the transforming.

(while normally not the solution: there is also an attribute for magento attributes that enables wysiwyg parsing and will be checked inside the productAttribute-function)

1

Try this code.

<?php 
$_product=Mage::registry('current_product');
$myattribute=$_product->getData('judaica_size_guide');
$_cmsHelper = Mage::helper('cms');
$_process = $_cmsHelper->getBlockTemplateProcessor();
echo $_process->filter($myattribute);

OR

<?php 
 $_product=Mage::registry('current_product');
 $myattribute=$_product->getData('judaica_size_guide');
echo $this->helper('catalog/output')->productAttribute($this->getProduct(),$myattribute,'description');
 ?>
0

Try single quotes inside curly braces that would not break wysiwyg, I had same problem which get solved doing that way.

<img src="{{image url='someurl'}}">
1
  • sadly it doesn't help, same result Mar 4, 2015 at 8:21
0

First of all, there is no image directive. To include files from the media directory, use the media template tag (double quotes are fine):

<img src="{{media url="wysiwyg/img.ext"}}" />

If you see the markup as is in the frontend, this may be caused

  • either by the WYSIWYG editor
  • or by your theme,

converting HTML special characters to HTML entities, e.g. < becomes &lt;. You may check the description stored in the database. If characters are already converted there, it's likely an issue during collection of data. Otherwise check your frontend display.

1
  • oh typo with image, I meant media of course. But still won't work and there is no html entity conversion, just the markup as it is pasted into the wysiwyg-editor (product page if it helps) As far as I can tell the installation is pretty much genuine Magento with just custom theme on top of it. Mar 4, 2015 at 10:25
0

Go to Admin/Catalog and enable the option for

"Allow Dynamic Media URLs in Products and Categories"

Change from "No" to "Yes" and then clear cache, {{media url=""}} now works ;)

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.