Add query strings to embedded youtube video in WYSIWYG

Joseph 's Avatar

Joseph

31 Jan, 2015 07:57 PM

Is there a way via the CMS to alter the src tag on an embedded youtube video inside a WYSIWYG? Currently, if a user directly copies the embed href it leaves out any query strings. We need to add "?wmode=transparent&rel=0" and it would be nice to not use a separate script for this feature.

  1. 1 Posted by Ryan Griffith on 02 Feb, 2015 02:09 PM

    Ryan Griffith's Avatar

    Hi Joseph,

    To confirm, are you looking to add these parameters to existing YouTube videos that were added by end users, perhaps through the WYSIWYG? If so, I think your best bet would be to use an XSLT Format attached to the Page, Config Set or Template level, which would allow you to alter the final rendered content of the page.

    This Format would basically target all applicable elements who's source attribute contains a YouTube URL. If the link does contain a YouTube URL, it would check to see if the URL contains the parameters and append them onto the end if they are not present.

    Another, simpler option, could be to add JavaScript to your pages that loops over the applicable tags and appends the parameters onto the end of the YouTube URLs if they do not already contain these parameters. If you're dealing with <iframe> embeds, this would also reload the iframe for you since altering the src triggers a reload event.

    Please let me know if you have any questions.

    Thanks!

  2. Ryan Griffith closed this discussion on 24 Feb, 2015 09:15 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac