Magento – Getting 404 cms_wysiwyg directive image URL

cmsmagento-enterprisenginxtinymcewysiwyg

Broken images

I noticed in the Magento CMS editor TinyMCE, the image thumbnails are set as the following format after a base64 encode of the shortcode {{media url="wysiwyg/foobar.gif"}}

index.php/admin/cms_wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l...

This is happening on nginx and not on apache. Perhaps it's an environmental issue however my question aims to solve this on the Magento layer.

404

My question is, how does Magento decode this ___directive... URL? and where?

Best Answer

The code for building these types of links appears to be done in getImageHtmlDeclaration function in the file /app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php

$html = Mage::helper('adminhtml')->getUrl('*/cms_wysiwyg/directive', array('___directive' => $directive));

The code for displaying these images is in the file /app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php

public function directiveAction

Here is loads the parameter, urlDecodes it using the core helper, uses the email template to produce the real url to the image.

I would suggest to look into file /lib/Varien/Filter/Template.php as this has the function filter which appears to be where the final url change happens. This will take the image in format:

{{skin url='images/home_main_callout.jpg'}}

And convert to a real url format.