littled.net

Web design & development; online and offline ramblings

Lorem

Plone and Flash Player 10

October 17th, 2008 · 11 Comments

Another pyrrhic victory maybe, but something that has made me exceptionally happy this afternoon. Basically, yesterday I upgraded my version of Flash Player to version 10 only to find that the Flash files on our Plone-powered site no longer worked.

The lovely folks at SWFObject helped to identify why this was happening — nothing to do with SWFObject at all but the fact that Flash Player 10 implements some new security “features”. I managed to isolate it to the fact that Plone serves up ATFiles with the header, “Content-Disposition: attachment”. Flash Player 10 ignores files served up with this header, so you need to override this and set it to “Content-Disposition: inline;”.

I came up with this solution which may not be overly elegant but at least it works. I created a skin-level Python script that sets response headers before returning the file:

showflash.py

request = container.REQUEST
RESPONSE =  request.RESPONSE
flashvid = request['flashvid']
cd = ‘inline; filename=%s’ %(context.id)
RESPONSE.setHeader(’Content-Disposition’, cd)
return context[flashvid]

Then, when I embed the video with SWFObject I call it thus,

<script type="text/javascript">
   swfobject.embedSWF("&dtml-portal_url;/path/to/flash/showflash?flashvid=myflash.swf", "my-dom-id", "435", "290", "9.0.115");
</script>

This may be better handled by a product like Plone4Artists Video but it certainly works as a fix for us.

Tags: UI · flash · plone · web design · web development · zope

11 responses so far ↓

  • 1 jarav // Oct 18, 2008 at 8:54 am

    Thanks. I have been ‘using’ Plone for a few months now but am still far, far from being comfortable with its internals. After going through the plone forums, the temporary solution that i found, was to change the code in three python files that set the content-disposition header. I knew what i was doing was wrong but didn’t know enough to come up with a solution like yours above.
    So, is this an external script to be placed in the Extensions folder?

  • 2 David // Oct 18, 2008 at 1:47 pm

    Hi,

    You can create this (Python) script anywhere within your site via the ZMI — you don’t have to do it as an External Method, although you could.

    The only problem with this approach is you need to be able to reference the script directly via a link etc. It won’t set the headers automatically for all Flash files in Plone. I guess that’s why other people were recommending hacking the Python files.

    Let me know if you need any more clarification.

    David

  • 3 jarav // Oct 18, 2008 at 8:06 pm

    Ok. Thanks. Thanks for the mail too.

  • 4 Jim // Oct 21, 2008 at 8:40 pm

    Thanks for the info - it’s submitted to the plone.org bug tracking system at: http://dev.plone.org/plone/ticket/8624

  • 5 David // Oct 24, 2008 at 1:24 pm

    Thanks for this Jim. From looking at some of the mails to plone-users this week this problem is starting to rear its ugly head all over the place.
    D.

  • 6 Anthony // Nov 11, 2008 at 8:52 pm

    David, have you tried implementing the fix in the ticket? I added it as shown to our staging server and restarted, but it didn’t fix it. But ticket notes it was tested in 3.1.6 and we are in 3.1.5. Not sure if that makes a difference.

  • 7 David // Nov 12, 2008 at 9:21 am

    Hi Anthony — I haven’t tried the fix yet. We’re still on 2.5.3 so am a bit hesitant to apply it. Thanks for the advice though. I’m surprised it doesn’t work. The fix appeared to change the content-disposition header to inline for .swf Files. Interesting!

  • 8 Bernard // Nov 12, 2008 at 5:24 pm

    Hey guys,

    I just wanted to say I’ve also added a patch for this problem in the Archetypes Product as we use a lot of custom type that has a file field.

    * open up Products/ArcheTypes/Field.py
    * Look for the “download” function in the “FileField” class
    * modify the following line:
    header_value = contentDispositionHeader(’attachment’, instance.getCharset(), filename=filename)
    :: to ::
    arr = filename.split(”.”)
    header_value = contentDispositionHeader(’inline’ if arr[len(arr) - 1] == ’swf’ else ‘attachment’, instance.getCharset(), filename=filename)

  • 9 Anthony // Nov 13, 2008 at 5:13 pm

    Just wanted to followup and say that the file.py fix did work. I think it was just a caching issue I wasn’t aware of that was throwing me off.

  • 10 Tony // Nov 18, 2008 at 7:57 am

    hello…

    i’m using plone 3.17 and the Archetypes/Field.py looks like this

    header_value = contentDispositionHeader(
    disposition=’attachment’,
    filename=filename)

    i changed these lines to the ones suggested but it broke my entire site i.e. the content of pages was relaced with

    so then i just replaced the word “attachment” for “inline” and like magic all Flash content appeared in my site again…

    this was a disaster though… since it messed up my permissions bigtime… admin user couldn’t even edit a page. i replaced the file with the original but still had the same error, and eventually i had to revert the entire site from backup.

    i’m trying to get ATFlashMovie working again. This fix http://plone.org/documentation/how-to/fixing-plones-publishing-of-flash-content-in-plone-3-1-6-and-earlier/ gets some of my flash that wasn’t inserted with ATFlashMovie to appear… The fix for ATFlashMovie on this page doesn’t work though. The only way to get it to appear was with Bernards suggestion that broke my site. I have lots of Flash inserted with ATFlashMovie and would really appreciate any suggestions to get it working again.

  • 11 sunflower // Nov 20, 2008 at 9:41 pm

    Thany you! This post did help me!
    The fix the was submitted on the Ticked worked for me, using Plone 3.1.2.
    http://dev.plone.org/plone/ticket/8624

Leave a Comment