Standards compliant flash

Last updated on
30 April 2025

There's an increasing interest in being able to create pages that comply with the W3C standards. Drupal pages are sent with the doc-type XHTML 1.0 Strict so if you want to use flash content AND remain compliant then SWF Tools will try to help out.

First, note that with SWF Tools 5 you can only get compliant code if you use the SWF Object 2 embedding method. With SWF Tools 6 you can get compliant code if you use SWF Object 2 or direct embedding, as the direct embedding code has been re-written.

This means that the mark up returned by the swf() function is valid HTML. However, that doesn't always mean you will get a compliant page. In general you probably will, but read on to find out when you may not!

In many applications users insert their flash content using the SWF Tools input filter which takes the form [swf file="somefile.swf"]. The SWF Tools filter turns that in to valid HTML for you. However, because of the effect of other (common) filters that may be running on your input it is possible for the swf code to get "wrapped" by other tags. In particular, if <p> tags get wrapped around the swf filter this will break validation. <p> tags are added by things like the Line break convertor which runs on many input formats.

SWF Tools tries to compensate for this by looking for an opening <p> and closing </p> tag immediately next to the filter. That catches, and fixes, the most common case where the swf filter appears on a line by itself in the input.

E.g. input such as
---
This is some text
[swf file="somefile.swf"]
This is more text
---

will produce a compliant page since any filter that attempts to add <p> tags will have them stripped again provided the SWF Tools filter runs after any filter that adds <p> tags. Again, in general the SWF Tools appears at the bottom of the list of filters by virtue of its name, but if you are not getting compliant code try re-arranging the filter order to make sure SWF Tools runs last.

However, if you place your swf filter inline with the text then SWF Tools will not detect the <p> tags, and you could end up with a <div> inside a <p> and that is no longer valid.

So, input such as
---
This is an inline [swf file="somefile.swf"] flash file
---

will probably not validate as there will most likely be <p> tags around the paragraph.

In cases where you really want to place the swf filter inline you would need an input format that does not include line break correction (e.g. the Full HTML format) in order that you control where the <p> tags go.

The same applies to code that produces mark up by calling the SWF Tools functions. Mark up returned from swf() is wrapped in a <div>, so you cannot wrap the output within tags such as <p> if you want compliant pages.

In summary, SWF Tools does the best it can to produce a compliant page for you. In many cases it will get it "right" and you shouldn't need to configure anything. But be aware of the exceptions, and if a page isn't producing valid code when you think it should please raise an issue on the issue queue (don't post issues below!)

Help improve this page

Page status: Not set

You can: