1

I will try to explain a strange behavior (maybe bug) when using WYSIWYG editor in Magento 1.9.

Magento setup

One website with three store views. Each store view is on different domains. For this case let’s focus only on two storeviews:

storeview 1: mywebshop.eu storeview 2: mywebshop.it

Steps for reproducing the error.

SCENARIO 1 which is OK.

  1. Open desired product, and open WYSIWYG for description field. Select storeview 1 (english)

  2. Add an image (using the editor’s button Insert/Edit image).

  3. The Html code I get is ok like this:

img src="{{media url="wysiwyg/adobe-pdf-icon-02.png"}}" /

The image is corectly displayed in frontend like this:

SCENARIO 2 which is not OK.

  1. RE-Open the same desired product and open WYSIWYG for description field. (Now select store view 2 (Italian)

  2. Add an image (using the editor’s button Insert/Edit image).

  3. Now the code I get is like this:

img src="{{media url="https://mywebshop.it/media/wysiwyg/adobe-pdf-icon-02.png"}}" /

The image in frontend is broken, because the HTML output is like this:

RESULT: the image is not displayed because of malformed img src.

We have recently setup Magento that each store view has a different domain. (Maybe this affects).

I saw very similar question here --> Wrong URL returned by WYSIWYG editor for images

But this answer doesn't help/work (Wrong URL returned by WYSIWYG editor for images)

Please help.

0

Option - 1

Open or extend (Overwrite) app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php file and update getImageHtmlDeclaration function.

Replace below code

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

To

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

Option - 2

Go to System > Configuration > Content Management (Under General) > WYSIWYG Options

Use Static URLs for Media Content in WYSIWYG for Catalog – Select “No”

I hope it will help you

  • I already tried option1, but it doesn't work ... maybe I missing something. Option 2 is not ok beacuse we want to to create a new website in the future and I believe this will create some problems ... – TheAgent Jun 20 at 12:30
  • UPDATE: Option 1 actualy resolves the issue. I just had the the class Mage_Cms_Helper_Wysiwyg_Images extended in another module... Thank you!! – TheAgent Jun 20 at 14:16
  • Please accept answer – Shorabh Jun 21 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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