Incompatible with JetPack Shortcode Embeds
-
We have been happily using your plugin for the past month or so while we’ve been developing a new website. However, yesterday, we activated JetPack and some of its modules, and found that your plugin no longer worked.
After a bit of digging, we figured out that the JetPack Shortcode Embeds module seems to short-circuit your plugin for some reason.
For instance, with a YouTube embed, the code that was output on the page prior to activating JetPack (with your plugin active) was something like:
<div class="fve-video-wrapper fve-image-embed fve-thumbnail-image youtube" style="padding-bottom:56.25%;"> <iframe src="//www.youtube.com/embed/PLLQK9la6Go?wmode=transparent&modestbranding=1&autohide=1&showinfo=0&rel=0" width="100%" height="100%" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe> </div>After we activate the Shortcode Embeds module in JetPack, we get the following instead:
<p><span class="embed-youtube" style="text-align:center; display: block;"><iframe class="youtube-player" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/PLLQK9la6Go?version=3&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1&wmode=transparent" frameborder="0" allowfullscreen="true"></iframe></span></p>I’ll try to look into this to see if I can figure out what changes might need to be made to your plugin, but if you have any ideas or might be able to come up with a fix faster than me, I’d appreciate it. Thank you.
-
I found the problem.
JetPack registers a bunch of new shortcodes when the Shortcode Embeds module is active. Two of those shortcodes are the
[youtube]and[vimeo]shortcodes.In the process, JetPack hooks into the
pre_ksesfilter to go through the content of the post and find anything that would have normally been oEmbedded, and replaces it with a call to those shortcodes instead.So, for example, if I have the following in my post:
https://www.youtube.com/watch?v=PLLQK9la6GoJetPack goes through the content and replaces it with something like:
[youtube]https://www.youtube.com/watch?v=PLLQK9la6Go[/youtube]The solution seems to be to remove the
[youtube]and[vimeo]shortcodes from the JetPack Shortcode Embeds module. To accomplish that, I used something like the code I posted in this Gist.Thanks.
As an aside, I also discovered that, within JetPack, there is a responsive-videos “tool” that doesn’t seem to work as well as your plugin (it doesn’t attempt to detect the ratio, nor does it expand the video to fit the full-width of a container that’s larger than the embedded video).
Within the code for the responsive-videos tool, JetPack hooks into the following three filters:
embed_oembed_html wp_video_shortcode video_embed_htmlUnfortunately, the
video_embed_htmlfilter only sends the HTML to be filtered; it doesn’t send the original URL, so, in order to use it, you’d have to attempt to deconstruct the HTML and find the appropriate URL.The
wp_video_shortcodefilter sends the HTML, along with a list of attributes (which includes thesrcattribute, which should match up with the URL).I’ve put together another Gist that shows an example of how this sort of thing might be achieved, so that we don’t have to blow away the
[youtube]and[vimeo]shortcodes altogether.
The topic ‘Incompatible with JetPack Shortcode Embeds’ is closed to new replies.