WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Shadowbox JS] Convert YouTube links to proper format?

[Plugin: Shadowbox JS] Convert YouTube links to proper format?

  • 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.

Viewing 1 replies (of 1 total)
  • 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.

    <?php
    function yt_sbox($content='') {
        return preg_replace('%youtube\.com/watch\?v=([^\&]+)%', 'youtube.com/v/$1', $content);
    }
    add_filter('the_content', 'yt_sbox', 9, 1);
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Shadowbox JS] Convert YouTube links to proper format?’ is closed to new replies.