The SWF Tools input filter

Last modified: September 7, 2008 - 20:26

The SWF Tools input filter is included as part of the core SWF Tools module, so when you enable SWF Tools the filter is available. The input filter lets you generate flash content and access the various media player modules by using a simple syntax of the form <swf file="myFlash.swf"> for a single file, or <swf files="Music1.mp3&&Music2.mp3&&...> for a list of files.

To use the input filter you must first assign it to some input formats where it will be allowed to be used. To do this go to Site configuration > Input formats and then choose Configure to add the filter to an existing input type, or choose Add input format to create a new format. Place a check next to the SWF Tools filter and then save the configuration. By default the SWF Tools filter is given a weight of 10 which means it will be one of the last filters to run, and generally this is the best option. If you need to re-arrange the filters then use the Re-arrange option on the input filters configuration page. The SWF Tools filter will need to come after any HTML corrector modules, or modules that strip tags. If the SWF Tools filter comes before these then there is a risk that the flash won't display. It can take some trial and error, but it is designed to work first time, as far as can ever be the case!

Once the filter has been activated you can start adding flash content to pages by using the <swf> format.

To add a single file simply write <swf file="myFile.swf">. Note - this will refer to a file in the default file directory of your site. If you want to refer to elsewhere then you can refer to sub-directories by using <swf file="subdirectory/anotherFile.swf">. If you want to refer to external files, or somewhere outside of the Drupal file system, then use a full path, such as <swf file="http://example.com/externalFile.swf">.

When you supply a filename to the SWF Tools filter then it will try to work out what to do with the file based on its extension. So swf files just get displayed, mp3 files are passed to the default mp3 player, and a list of flv's would go to the configured flv player.

To refer to a list of files replace <swf file="oneFile.swf"> with <swf files="Music1.mp3&&Music2.mp3&&...">. Note that in the list of files double ampersands are used to separate each file! Behind the scenes SWF Tools will convert the list of files in to an appropriate format for the media player that is going to be used.

If you have used an earlier version of SWF Tools then existing nodes that use the format <swflist files="..."> will still work. However, it is no longer necessary to use the <swflist> syntax since just passing either file or files is enough to tell SWF Tools what to do.

Over-riding the embedding method

If necessary the default embedding method can be over-ridden by passing the parameter embed="{method}" in the filter, where {method} is the method name you want to use. The method name is an internal name that SWF Tools uses to identify available methods.

Method Method name
Direct embedding swftools_nojavascript
SWF Object 2 swfobject2_replace
SWF Object 1.5 swfobject_replace
jQUery Flash lutman_replace
UFO ufo_replace

Forcing a specific media player

Sometimes you may want to force SWF Tools to use a specific player to play back a media item. This might occur if you want to use a player other than the default, or if the auto-detection of the media type is failing.

To force a specific player use the parameter player="{player}" in the filter, where {player} is the player name you want to use. The player name is an internal name that SWF Tools uses to identify available players.

Player Player name
FlowPlayer flowplayer_mediaplayer
JW Image Rotator 3 wijering_imagerotator
JW Media Player 3 wijering_mediaplayer
JW Media Player 4 wijering4_mediaplayer
Simple Viewer simpleviewer
1 Pixel Out Player onepixelout

Forcing a specific action

Sometimes you may want to force SWF Tools to use a specific action to play back a media item. This might occur if the auto-detection of the media type is failing so the wrong action is being assigned.

To force a specific action use the parameter action="{action}" in the filter, where {action} is the action name you want to use. The action name is an internal name that SWF Tools uses to identify available actions.

Action Action name
Display as an swf (no player) swftools_swf_display_direct
Play a single mp3 swftools_mp3_display
Play a list of mp3s swftools_mp3_display_list
Play a single flv swftools_flv_display
Play a list of flvs swftools_flv_display_list
Play a list of images swftools_image_display_list
Play a list of mixed media swftools_media_display_list
 
 

Drupal is a registered trademark of Dries Buytaert.