Magento2: 2.2.0-dev - cms images are being added as __directive for path

Created on 24 Oct 2016  Â·  19Comments  Â·  Source: magento/magento2

Preconditions

  1. php 5.6
  2. centos 6.5
  3. Magento 2.2.0-dev

    Steps to reproduce

  1. create page in cms or block
  2. upload image using insert image
  3. 3.

Expected result

  1. image should be in path http://www.examplesite.com/pub/media/xxx/xxx.etc

Actual result

  1. image path random in terms of letters and numbers but always contains links like below
    https://www.example.com/admin_url/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvVmlkZW9zX2hvbWVwYWdlX3BpYy5qcGcifX0%2C/key/433d962b838e3448a2f0bf126627f57f98995b767c13bc09e8122e3b2501cdd6/
Catalog Fixed in 2.2.x Confirmed Format is valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x bug report

Most helpful comment

I need this too, on 2.1.3! Anyone has a fix himself?!

All 19 comments

Such URL exists only on backend in WYSIWYG area, if you open CMS page/block on frontend URL will be like http://www.example.com/media/wysiwyg/.
Such behavior is not a bug.
If you see same URL on frontend as on backend, provide more details please.

Nope. That url was taken from frontend. I am not getting media/wysiwyg

On Wed, Oct 26, 2016 at 7:48 AM, Mykola Palamar [email protected]
wrote:

Such URL exists only on backend in WYSIWYG area, if you open CMS
page/block on frontend URL will be like http://www.example.com/media/
wysiwyg/.
Such behavior is not a bug.
If you see same URL on frontend as on backend, provide more details
please.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/magento/magento2/issues/7167#issuecomment-256370432,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ANFpTGu1ggmuVq0myMGTmZJ1cIPhftQsks5q32gvgaJpZM4KfSpi
.

Vasari Plaster and Stucco, LLC
Web Support Specialist
805-845-2497

I need more details, as in my case all works as expected.
Do you have additional stores, how you store images (filesystem or database), where HTTPS is turned on (only frontend, only backend, on both).
Thanks.

No additional stores. I have it stored as filesystem. HTTPS is disabled on frontend, enabled in admin.

@palamar: we also see this, see this slightly related issue: https://github.com/magento/magento2/issues/7215

Duplicates: 5705

But even that ticket is still not solved. Mainly because developers cannot replicate the issue.
I just had it too. But I didn't have it before. Something changed. Still figuring out what though.

Unfortunately, no fixes yet for me and is probably related but not the same issue. Anyone have a fix for this?

I need this too, on 2.1.3! Anyone has a fix himself?!

Still an issue in EE 2.1.4

For anyone still struggling with this, we've came up with a fairly straightforward fix (props to the people at Vaimo). This was tested on EE 2.1.4

  1. Add this to etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
     <type name="Magento\Cms\Model\Wysiwyg\Config">
         <plugin name="add_wysiwyg_data" type="Vaimo\ModuleName\Plugin\WysiwygConfigPlugin" sortOrder="30" />
     </type>
</config>
  1. Create a Plugin at Plugin/WysiwygConfigPlugin.php with:
<?php
namespace Vaimo\ModuleName\Plugin;

use Magento\Cms\Model\Wysiwyg\Config;
use Magento\Framework\DataObject;

/**
 * Class to handle plugins on Magento\Cms\Model\Wysiwyg\Config
 */
class WysiwygConfigPlugin
{
 /**
 * Adds parameter to allow correct embedding of images
 *
 * @param Config $subject
 * @param DataObject $config
 *
 * @return DataObject
 */
 public function afterGetConfig(Config $subject, DataObject $config)
 {
 $config->addData(['add_directives' => true]);

 return $config;
 }
}
  1. Use this function in the template files to get the proper output.
    Otherwise it will contain directives (like {{media url=""}). This assumes that $block->getProduct() is available in the template. For example $block \Magento\Catalog\Block\Product\View\Description works fine.
<?php /* @escapeNotVerified */ echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getData('some_attribute'), 'some_attribute'); ?>

@dmcmillin thank you for your report.
We have created internal ticket MAGETWO-58156

@dmcmillin, thank you for your report.
We've created internal ticket(s) MAGETWO-69962 to track progress on the issue.

Yep. Same issue on 2.2

The above pr fixed the issue for me.

Created a detailed description on how to reproduce this error in #12741 asked to reopen the PR of @jsiefer which fixed this issue. Let's hope this one gets merged and released in the next version, because it's quite a pain to work with the WYSIWYG editor right now.

This issue is fixed in Magento 2.2.2. I have tested this and works fine with this release of Magento. This issue can be closed.

Hi @dverkade thank you for deep research and linking all together. Closing this issue

Fixed in: https://github.com/magento/magento2/pull/11048

We upgraded to v2.2.2 and I'm still getting the issue. What is necessary to fix it as anything that manages to sneak into content with one of these __directive links hangs the process in apache in a 'closing' state that consumes 100cpu and don't go away until manually killed.

UPDATE: I searched the database to try to find links and didn't find any, so I searched the codebase instead. I noted in our version of the Cleversoft theme code it appears to be building urls similar to the ones that are hanging, but a third party developer we hired to customize our site built their changes over the top of the theme itself so we can't easily update it. I'm putting some fire on them to refactor their code so I can update the theme before doing further trouble-shooting as I suspect the [older] theme code as a potential source of our woes.

I had issues with wysiwyg images on Magento 2.2.2.
As I couldn't find ready solution anywhere, I'm sharing my observation here:
In file /vendor/magento/module-cms/Helper/Wysiwyg/Images.php there's a method isUsingStaticUrlsAllowed.
It passes "isAllowed" argument through event so you can easily override it in your code.

Was this page helpful?
0 / 5 - 0 ratings