I’ve been tinkering with The Time theme these past few days, integrating a Flash player shortcode into it. Flash is rarely used on most sites today — it’s mostly Tudou and Youku videos. But many people don’t know how to convert Flash files to video format, so they can’t embed them in posts (the WordPress editor does support this, but it’s not very convenient). Here’s how to embed Flash in WordPress posts:
The method is similar to my recent tutorial on integrating an MP3 player in WordPress. Add the following code to your theme’s functions.php:
function swf_player($atts, $content = null) {
extract(shortcode_atts(array("width"=>'480',"height"=>'360'),$atts));
return '<embed type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'" src="'.$content.'"></embed>';
}
add_shortcode('swf','swf_player');
Usage:
[swf]Flash file URL[/swf]
Insert the code above in your post to add a Flash player. This shortcode supports two parameters — width and height — with defaults of 480 wide and 360 tall. To customize the Flash dimensions:
[swf width="400" height="300"]Flash file URL[/swf]