You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When pasting in the embed code into the text area, everything works fine. However, if a user goes to edit the shortcake (update a cover image or what have you), many of the html entities have been converted to their unicode(?) entities.
For example, this: <a data-flickr-embed="true" href="https://www.flickr.com/photos/flickr/albums/72157639858715274" title="Flickr Friday"><img src="https://farm3.staticflickr.com/2838/33797934960_4b586dbcfb_b.jpg" width="1024" height="768" alt="Flickr Friday"></a><script async src="//embedr.flickr.com/assets/client-code.js" charset="utf-8"></script>
WP replaces <script> and <style> tags in the editor with an image placeholder - see here
We could decode those placeholders in the same way as core does when opening up the shortcode to edit, I haven't put much thought yet into how many edge cases we might need to support for that.
A workaround that might work until the issue is addressed is to use an regular textarea attribute field with 'encoded' => true set, rather than using the inner_content attribute, so that tinymce doesn't have a chance to mangle the value in the first place.
We have a shortcode registered via the UI that allows users to embed Flickr galleries in posts. The UI is registered like so below:
When pasting in the embed code into the text area, everything works fine. However, if a user goes to edit the shortcake (update a cover image or what have you), many of the html entities have been converted to their unicode(?) entities.
For example, this:
<a data-flickr-embed="true" href="https://www.flickr.com/photos/flickr/albums/72157639858715274" title="Flickr Friday"><img src="https://farm3.staticflickr.com/2838/33797934960_4b586dbcfb_b.jpg" width="1024" height="768" alt="Flickr Friday"></a><script async src="//embedr.flickr.com/assets/client-code.js" charset="utf-8"></script>
Becomes this:
<a data-flickr-embed="true" href="https://www.flickr.com/photos/flickr/albums/72157639858715274" title="Flickr Friday"><img src="https://farm3.staticflickr.com/2838/33797934960_4b586dbcfb_b.jpg" width="1024" height="768" alt="Flickr Friday"></a><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20async%20src%3D%22%2F%2Fembedr.flickr.com%2Fassets%2Fclient-code.js%22%20charset%3D%22utf-8%22%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="<script>" title="<script>" />
Obviously, stripping the
<script>
tags prevents the embed from working properly.Does anyone know how to ensure that the text area preserves the code as originally pasted? Is this a Wordpress issue perhaps?
The text was updated successfully, but these errors were encountered: