سؤال

When I try to insert an image to the wysiwyg editor in Magento it places the right variable of the image path in the media directory.

But, wysigyg doesn't find the right path/url, example:

I inserted:

<p><img src="{{media url="wysiwyg/blog/Screen_Shot_2013.png"}}" alt="" /></p>

But, in the preview it gets me the next broken src:

<img src="https://localhost/index.php/admin/cms_wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ii93eXNpd3lnL2Jsb2cvU2NyZWVuX1Nob3RfMjAxMy5wbmcifX0,/key/1a966015551bf00867319d23c9914b48/" alt="" data-mce-src="https://localhost/index.php/admin/cms_wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ii93eXNpd3lnL2Jsb2cvU2NyZWVuX1Nob3RfMjAxMy5wbmcifX0,/key/1a966015551bf00867319d23c9914b48/">

And of course, it doesn't show the image. Also this happens with links and other media files.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

The option wich Le Nguyen gave is not really a good solution.

Like hsanders said:

There are some pretty big drawbacks to doing this: The static URL will be a non-secure URL and If you change your base URL the URLs on the images will not update to reflect that are the two I can think of immediately.

A possible solution to "fix" the problem (not the right way in my opinion, but at least better than the static Url option) would be to add some code to the following file:

vendor/magento/module-catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Add on line 747:

'add_variables' => false,
'add_widgets' => false,
'add_directives' => true,

Also change lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js and add the following on line 384 (below content = editor.getContent();:

content = this.decodeContent(content);

Now you need to execute the following command to complete the process:

php bin/magento cache:flush

Hope this helps.

(Keep in mind you've just edited core files)

in your Form.php you configuration should be like below

    protected function _prepareForm()
      {

     $model = Mage::registry('testimonial_data'); 
      $form = new Varien_Data_Form();
      $this->setForm($form);

      $form->setHtmlIdPrefix('testimonial_');
      $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => false,'files_browser_window_url'=>$this->getBaseUrl().'admin/cms_wysiwyg_images/index/'));

  $fieldset->addField('content', 'editor', array(
          'name'      => 'content',
          'label'     => Mage::helper('testimonials')->__('Content'),
          'title'     => Mage::helper('testimonials')->__('Content'),
          'style'     => 'width:700px; height:500px;',
          'state'     => 'html',
          'config'    => $wysiwygConfig,
          'required'  => true,
      ));
}

hope it will work for you.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top