Unable to add image via Magento Cms wysiwyg editor

When I tried to add the image through the wysiwyg editor and tried to save the page, it took too long to respond, I got the following error

a:5:{i:0;s:25:"Unsupported image format.";i:1;s:1001:"#0 /var/www/html/project1/lib/Varien/Image/Adapter/Gd2.php(51): Varien_Image_Adapter_Gd2->_getCallback('create') #1 /var/www/html/project1/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php(52): Varien_Image_Adapter_Gd2->open('http://121.0.0....') #2 /var/www/html/project1/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Adminhtml_Cms_WysiwygController->directiveAction() #3 /var/www/html/project1/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('directive') #4 /var/www/html/project1/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #5 /var/www/html/project1/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() #6 /var/www/html/project1/app/Mage.php(683): Mage_Core_Model_App->run(Array) #7 /var/www/html/project1/index.php(87): Mage::run('', 'store') #8 {main}";s:3:"url";s:150:"/index.php/admin/cms_wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvcmd0LXNsaWRlci1pbWcwMS5qcGcifX0,/key/ceed8184f5f336aafcc307f8623aff45/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";} 

Even though the page is saved, I can’t view the image in the CMS editor

+4
source share
6 answers

The problem is that Magento creates a dynamic link with an admin path in it. See line 8 in your error: /index.php/admin/cms_wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvcmd0LXNsaWRlci1pbWcwMS5qcGcifX0,/key/ceed8184f5f336aafcc307f8623aff45/

Since this link does not have a known image extension at the end, I assume that the error you received has occurred.

The solution is to change only one parameter in admin:

System -> Configuration -> General -> Content Management -> Use Static URLs for Media Content in WYSIWYG for Catalog to Yes

I found that this option is marked in /app/code/core/Mage/Cms/Helper/WYSIWYG/Images.php on line 180 (in Magento 1.7.0.2) and depending on whether static or dynamic links are generated.

+8
source

This is a Magento bug when considering a particular repository.

Rewrite the getImageHtmlDeclaration() method from Mage_Cms_Helper_Wysiwyg_Images to change the source code:

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

to

 $mediaPath = str_replace(Mage::app()->getStore($this->_storeId)->getBaseUrl('media'), '', $fileurl); 
+2
source

Have you checked if allow_url_fopen is allowed on this server? Today I faced the exact same problem, and that changed this problem.

There are several ways to change this:

  • php.ini
  • Apache configuration
  • Vhost configuration
  • .htaccess

You need to choose the best method that is suitable for setting up your web server.

I fixed mine by modifying the Apache VirtualHost configuration file to fix it:

 php_admin_value allow_url_fopen on 
0
source

Update your magento cache and flush everything

0
source

An exception occurs when editing a cms page containing images from the skin folder. Because when we use the custom admin theme, the placeholder image is not available in TinyMCE adminhtml.

Fix: copy the placeholder image from adminhtml / default / default / to the user theme and it will stop exceptions like this.

 /skin/adminhtml/default/THEME/images/wysiwyg/skin_image.png 

image image placeholder for TinyMCE

0
source

I had a similar problem. The solution was to create the / media / wysiwyg folder

-1
source

All Articles