help adding simple tag to MCE (2 posts)

  1. notwen
    Posted 10 years ago #

    Hi All -- if you go to http://www.whittenweb.com you will likely see what i'm trying to do.

    I'm not very experienced with writing wp plugins. What I would like to do is create a simple tag (like

    <yte>{youtube video id}</yte> and have that expand when a post is viewed to the following:

    <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/{youtube video id}"></param><embed src="http://www.youtube.com/v/{youtube video id}" type="application/x-shockwave-flash" width="425" height="350"></embed></object>

    This seems fairly simple -- just not sure i'm looking in the right places on where i'd add this type of code. Any help?


  2. notwen
    Posted 10 years ago #

    Never mind -- I figured it out -- easy of course, once I could figure out where to put it!

    Plugin Name: You Tube Embed
    Plugin URI: <none yet>
    Description: Adds quicktags for embedding youtube videos in your blog
    Version: 1.0
    Author: Notwen
    Author URI: <none yet>


    Drop in your /wp-content/plugins/
    Activate the plug-in via admin


    add_filter('the_content', 'notwen_yte');

    function notwen_yte($post_content)
    $pattern ='@<yte>(.*?)</yte>@';
    $replace = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>';
    return preg_replace ($pattern, $replace, $post_content);


Topic Closed

This topic has been closed to new replies.

About this Topic