I spent a long time earlier trying to find a Flash plugin for WordPress that worked OK, until I decided to just make my own function. Piece of cake! Why didn't I try this earlier.
I used this code from CSS Tricks, checked the Shortcode API page on WordPress and combined a sample function code:
function my_shortcode_handler( $atts, $content = null ) {
$a = shortcode_atts( array(
'attr_1' => 'attribute 1 default',
'attr_2' => 'attribute 2 default',
// ...etc
), $atts );
}
...with the embed code:
<object type="application/x-shockwave-flash"
data="your-flash-file.swf"
width="0" height="0">
<param name="movie" value="your-flash-file.swf" />
<param name="quality" value="high"/>
</object>
...and here's the result!
add_shortcode( 'swf', 'shortcode_swf' );
function shortcode_swf( $atts ) {
extract(shortcode_atts(array(
"url" => '',
"width" => '580',
"height" => '400',
"quality" => 'high',
), $atts ));
return '<div class="flash"><object type="application/x-shockwave-flash" data="'.$url.'" width="'.$width.'" height="'.$height.'"><param name="movie" value="'.$url.'" /></object></div>';
}
Embedding a Flash file is as simple as with any other plugin, simply use the shortcode created above like this: [swf width="580" height="160" url="http://site.ext/swf/1/file.swf" width=550 height=400]
In difference from most outdated plugins out there, this one doesn't rely on JS to work either.
You can add in extra attributes if you like, or how about adding a 'parameters' attribute through which you can add in any and all parameters directly via the shortcode? For me though, this is all I need.
Comments
The Comment Form
© CyberD.org 2025
Keeping the world since 2004.
cool! now we can (simply) play Flash games on blogging platforms
Simply put it's pretty simple now. :) I have a bunch of those left to post too. Old NG stuff. From back in the day. Before it disappeared. All I really got around to porting back then was the Music Player series... which I'm pondering if I should keep up because not all of them are probably entirely legal and since this is my own site I suppose I'm responsible for such things... it was easier when they were up on NG and it was up to them! Guess I'll see what happens...