The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[Plugin: Shadowbox JS] Convert YouTube links to proper format? (2 posts)

  1. Hesadanza
    Posted 6 years ago #

    All of the YouTube links on my blog are directed to the YouTube video page, not directly to the videos. Can the Shadowbox plugin automatically convert the links from the format "watch?v=" to "v/" so that they will play within the Shadowbox? Perhaps it could be given as an option in the settings? Right now if you click on these links, an empty shadow box appears.

  2. Matt Martz
    Posted 6 years ago #

    The Shadowbox JS plugin does not automatically do this. Could it? Yes. Will it? Possibly.

    This code placed in a new plugin or in your themes functions.php should work. Note: This code is untested.

    function yt_sbox($content='') {
        return preg_replace('%youtube\.com/watch\?v=([^\&]+)%', 'youtube.com/v/$1', $content);
    add_filter('the_content', 'yt_sbox', 9, 1);

Topic Closed

This topic has been closed to new replies.

About this Topic