Support » Plugins and Hacks » [Resolved] [Plugin: swfObject Reloaded] Can this plugin be used in templates?

[Resolved] [Plugin: swfObject Reloaded] Can this plugin be used in templates?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author CodeAndReload


    There isn’t any need to. The Flash object is automatically inserted onto the attachment pages with the parameters specified on the attachment.

    Then I’m still missing something I’m afraid.

    When I add the swf (choosing post url), I get this code inside my post:

    This will open the swf inside the post, but I would like to open this swf inside the attachment page. I made two attachment pages to be sure: attachment.php and application.php. Inside I use the_content(), because I thought that was the only thing necessary.

    Plugin Author CodeAndReload


    That should be the only thing necessary, provided the the_content filter (mc_content) function runs, the post has a mime-type of ‘application/x-shockwave-flash’, it is not a feed (is_feed() is false)

    Some things to check:

    • the_content filters are being applied
    • Nothing is changing the_content as it is filtered after mc_content is run, maybe a plugin is changing the content after mc_content is run
    • the media’s mime-type is “application/x-shockwave-flash”
    • is_feed is false
    • the $post global is initialized and is correct, perhaps a plugin is changing the $post global?

    A filter is applied early to the_content:

    add_filter( "the_content", "mc_content", -9999999999999999999);

    And when the filter is called on an attachment-page (attachment.php) the post object’s mime-type should be “application/x-shockwave-flash” then the filter should add that stuff

    function mc_content ($content) {
    		global $post;
    		if (true && is_feed() && trim($post->post_content)) {
    			global $post, $shortcode_tags;
    			$tempElem = $shortcode_tags["swfobject"];
    			$contentA = strip_shortcodes( $post->post_content );
    			$shortcode_tags["swfobject"] = $tempElem;
    			$content = do_shortcode($contentA);
    			return $content;
    		} elseif(is_feed()) {
    			return $content;
    		} <strong>elseif (get_post_mime_type( $post->ID )=="application/x-shockwave-flash"){
    			return "" . mc_swf_shortcode( null, $post->ID) . "<p>" .$post->post_excerpt ."</p><p>"  .$post->post_content ."</p>";
    		else return $content;

    Here is a live example, so I know it does work on an attachment page.

    WordPress does have functions to check the post’s mime type, and a way to treat a string as if it had been run through all the shortcodes.

    if (get_post_mime_type( $the_posts_ID )=="application/x-shockwave-flash"){
       echo do_shortcode("[swfobject]$the_posts_ID[/swfobject]");

    The above code should work as a kluge, but It would be nice to know why it isn’t working. You’ll need to change ‘$the_posts_ID’ with the post’s id.

    [Please post code snippets between backticks or use the code button.]

    Damn, i’m still missing something I quess. Let me describe everything as good as I can…

    The post’s mime type is correct. When I insert

    if (get_post_mime_type( $the_posts_ID )=="application/x-shockwave-flash"){
       echo do_shortcode("[swfobject]$the_posts_ID[/swfobject]");

    it shows me the flash file twice on that page. Once inside the post, once because of this code.

    Second: Perhaps everything is working ok, but shouldn’t I first GET to the attachment page? Doesn’t the code


    only insert the swf at that point in the post? Shouldn’t it first be a link the the attachment ID so it will open in attachment.php?

    Also, I don’t understand what mc_content is. Is this part of your plugin? Do I have to insert that somewhere in my template?

    I tried everything I can. I added is_feed and global $post checks to the attachment.php page, but I still feel that I can’t ‘reach’ the attachment.php page because the current code only inserts the flash. There is no actual link to the file.

    @codeandreload: I think this can’t be done with your plugin at this moment, but I managed to add the links manually inside application.php.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] [Plugin: swfObject Reloaded] Can this plugin be used in templates?’ is closed to new replies.