4

I've noticed a weird behavior from the WYSIWYG editor in the product description. Whenever I insert an image it will output

<img src="{{media url="http://example.com/media/wysiwyg/the-picture.jpg"}}" alt="" />

while in another context, such as static blocks editing, it would output

<img src="{{media url=wysiwyg/the-picture.jpg"}}" alt="" />

This results in displaying

<img alt="" src="http://example.com/media/http://example.com/media/wysiwyg/the-picture.jpg">

which is obviously not what I want.

I've searched on different topics, and no one seems to have that specific problem. Did anyone come across this, does anyone have a fix?

2
  • have same problem in 1.9.0.1. any solution pls Jun 5, 2015 at 6:19
  • 1
    i feel your pain here - i have the same issue. shame nobody could give you the answers you were looking for :(
    – Jimmery
    Sep 10, 2015 at 9:04

4 Answers 4

5

the error is due to Mage::getBaseUrl('media') does not pass the store parameter !

To solve this bug, change in :

app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php

Find function : getImageHtmlDeclaration

and change :

$mediaPath = str_replace(Mage::getBaseUrl('media'), '', $fileurl);

by

$mediaPath = str_replace(mage::app()->getStore($this->_storeId)->getBaseUrl('media'), '', $fileurl);
3

If you look at the file Mage_Adminhtml_Catalog_ProductController you will see where it add the store url for product wysiwyg.

$storeMediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

$content = $this->getLayout()->createBlock('adminhtml/catalog_helper_form_wysiwyg_content', '', array(
    'editor_element_id' => $elementId,
    'store_id'          => $storeId,
    'store_media_url'   => $storeMediaUrl,
));

My suggestion for you would be to look into this and debug what exactly is being passed to the config. It might also be worth comparing how this is done in cms pages.

5
  • Thanks for bringing that up, I'll try and have a look at it. Tbh I moved on to something else since then, but +1 for pointing out a specific spot to look up. May 23, 2014 at 12:19
  • @JulienLachal are you still getting the issue? May 23, 2014 at 12:20
  • I bet my client does, but I told them how to correct that. May 23, 2014 at 12:21
  • Any luck with this? I got same issue in Magento 1.9.0.1
    – Jaro
    Jan 16, 2015 at 9:25
  • have same problem in 1.9.0.1. any solution pls Jun 5, 2015 at 6:18
1

Check the following configuration setting: System -> Configuration -> Catalog -> Catalog -> Frontend -> Allow Dynamic Media URLs in Products and Categories

1
  • I've checked and it's set to "Yes" already :/ Mar 6, 2014 at 9:07
1

Use the following code.

<img src="{{media url="/wysiwyg/the-picture.jpg"}}" alt="" />

the media url 'll give the store media url like http://www.yourdomain.com/media

to get Store Url

{{store url=""}}

to get Skin Url

{{skin url=""}}

More Details Refer this

1
  • Thank you, but it does not answer my question in any way. My problem is that the url generated by the WYSIWYG editor is wrong, and I'd like it to give me the right URL all the time without having to modify it by hand. Mar 6, 2014 at 9:06

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.