Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter smartyd

    (@smartyd)

    This is the Youtube plugin code:

    // Youtube Code
    
    define("YOUTUBE_WIDTH", 260); // default width
    define("YOUTUBE_HEIGHT", 200); // default height
    define("YOUTUBE_REGEXP", "/\[youtube (:print:+)\]/");
    define("YOUTUBE_TARGET", "<object width=\"###WIDTH###\" height=\"###HEIGHT###\"><param name=\"movie\" value=\"http://www.youtube.com/v/###URL###&fs=1&border=1&color1=0x2b405b&color2=0x6b8ab6\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><embed src=\"http://www.youtube.com/v/###URL###&fs=1&border=1&color1=0x2b405b&color2=0x6b8ab6\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"###WIDTH###\" height=\"###HEIGHT###\"></embed></object>");
    
    function youtube_plugin_callback($match)
    {
    	$tag_parts = explode(" ", rtrim($match[0], "]"));
    	$output = YOUTUBE_TARGET;
    	$output = str_replace("###URL###", $tag_parts[1], $output);
    	if (count($tag_parts) > 2) {
    		if ($tag_parts[2] == 0) {
    			$output = str_replace("###WIDTH###", YOUTUBE_WIDTH, $output);
    		} else {
    			$output = str_replace("###WIDTH###", $tag_parts[2], $output);
    		}
    		if ($tag_parts[3] == 0) {
    			$output = str_replace("###HEIGHT###", YOUTUBE_HEIGHT, $output);
    		} else {
    			$output = str_replace("###HEIGHT###", $tag_parts[3], $output);
    		}
    	} else {
    		$output = str_replace("###WIDTH###", YOUTUBE_WIDTH, $output);
    		$output = str_replace("###HEIGHT###", YOUTUBE_HEIGHT, $output);
    	}
    	return ($output);
    }
    function youtube_plugin($content)
    {
    	return (preg_replace_callback(YOUTUBE_REGEXP, 'youtube_plugin_callback', $content));
    }
    
    add_filter('the_content', 'youtube_plugin',1);
    add_filter('the_content_rss', 'youtube_plugin');
    add_filter('comment_text', 'youtube_plugin');
    
    ?>

    Anyone know what about this is not xhtml compliant?

    Thread Starter smartyd

    (@smartyd)

    Well, using advice from this site (http://www.sohtanaka.com/web-design/valid-xhtml-youtube-embed-code/) I got the page to validate, but I can’t get it to obey any height and width definition. Here is the stripped code that validates:

    // Youtube Code
    
    define("YOUTUBE_REGEXP", "/\[youtube (:print:+)\]/");
    define("YOUTUBE_TARGET", "<object type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/v/###URL###&fs=1&border=1&color1=0x2b405b&color2=0x6b8ab6\"><param name=\"movie\" value=\"http://www.youtube.com/v/###URL###&fs=1&border=1&color1=0x2b405b&color2=0x6b8ab6\" /></object>");
    
    function youtube_plugin_callback($match)
    {
    	$tag_parts = explode(" ", rtrim($match[0], "]"));
    	$output = YOUTUBE_TARGET;
    	$output = str_replace("###URL###", $tag_parts[1], $output);
    	return ($output);
    }
    function youtube_plugin($content)
    {
    	return (preg_replace_callback(YOUTUBE_REGEXP, 'youtube_plugin_callback', $content));
    }
    add_filter('the_content', 'youtube_plugin',1);
    add_filter('the_content_rss', 'youtube_plugin');
    add_filter('comment_text', 'youtube_plugin');
    ?>

    I tried adding a “class” inside the object and defining the height and width in the CSS stylesheet, but nothing. Any ideas? Thanks

    Thread Starter smartyd

    (@smartyd)

    RESOLVED. Borrowed from the google_video code to achieve the final code for youtube (no CSS needed):

    define("YOUTUBE_WIDTH", 260);
    define("YOUTUBE_HEIGHT", 200);
    define("YOUTUBE_REGEXP", "/\[youtube (:print:+)\]/");
    define("YOUTUBE_TARGET", "<object type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/v/###URL###&border=1&color1=0x2b405b&color2=0x6b8ab6\" width=\"".YOUTUBE_WIDTH."\" height=\"".YOUTUBE_HEIGHT."\" ><param name=\"movie\" value=\"http://www.youtube.com/v/###URL###&border=1&color1=0x2b405b&color2=0x6b8ab6\" /></object>");
    
    function youtube_plugin_callback($match)
    {
    	$tag_parts = explode(" ", rtrim($match[0], "]"));
    	$output = YOUTUBE_TARGET;
    	$output = str_replace("###URL###", $tag_parts[1], $output);
    	return ($output);
    }
    function youtube_plugin($content)
    {
    	return (preg_replace_callback(YOUTUBE_REGEXP, 'youtube_plugin_callback', $content));
    }
    add_filter('the_content', 'youtube_plugin',1);
    add_filter('the_content_rss', 'youtube_plugin');
    add_filter('comment_text', 'youtube_plugin');
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: WordPress Video] validation error’ is closed to new replies.