The SWF Tools input filter

Last modified: August 17, 2009 - 21:35

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!

If you find you get some of the SWF Tools embedding content actually displaying on the page then double check the filter settings. If you have several filters with the same weight as SWF Tools then try weighting SWF Tools more heavily, or lighten the others.

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, unless you are using the Drupal 5 version, 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

Specifying flashvars

If you want to send a string of flash variables to the movie then you can include this in the input filter by writing <swf file="myMovie.swf" flashvars="var1=Something&&var2=SomethingElse">

Note that you have to use a double ampersand, and that you cannot include an unescaped quote in the flashvars string as this will confuse the filter!

Setting flash video player size using swf filter

James Marks - May 1, 2009 - 22:54

It's possible, although not immediately obvious, to set other parameters for the video player such as height and width using the swf input filter like:
[swf file="flash_video_file.flv" params="width=400&&height=300"]

Forcing a flash version

andraaspar - May 22, 2009 - 10:22

It would be worth to mention that you can force a flash version that is different from the default, by using:

[swf file="flash/myflash.swf" params="version=10.0.22"]

This square bracket

martysteer - November 5, 2009 - 09:46

This square bracket replacement is my preferred option. I tried the hack below for the last month and TinyMCE leaves mce_bogus and mce_href attributes throughout all my other edited pages.

TinyMCE scrubbing

koppie - June 4, 2009 - 20:38

Even though I checked all the right options, TinyMCE was still scrubbing out my calls. Even though this has been discussed elsewhere, I couldn't find any newbie instructions for the new Drupal 6 WYSIWYG module with TinyMCE, so here you go:

(1) Edit /sites/all/modules/wysiwyg/editors/tinymce.inc
(2) Find "function wysiwyg_tinymce_settings($editor, $config, $theme) {" and add "'cleanup' => FALSE," to the end of it, so it looks like this:

function wysiwyg_tinymce_settings($editor, $config, $theme) {
  $init = array(
    'button_tile_map' => TRUE, // @todo Add a setting for this.
    'document_base_url' => base_path(),
    'mode' => 'none',
    'plugins' => array(),
    'theme' => $theme,
    'width' => '100%',
    // Strict loading mode must be enabled; otherwise TinyMCE would use
    // document.write() in IE and Chrome.
    'strict_loading_mode' => TRUE,
    // TinyMCE's URL conversion magic breaks Drupal modules that use a special
    // syntax for paths. This makes 'relative_urls' obsolete.
    'convert_urls' => FALSE,
    'cleanup' => FALSE,
  );

Note: by doing this, you've completely turned off TinyMCE's scrubbing feature. This is not recommended by people who know better.

Ooh

greg.harvey - September 24, 2009 - 16:18

And kittens will die, you hacker you!

Surely there's a GUI option to turn off clean-up?

Thank you koppie, it works.

adVid - October 30, 2009 - 14:06

Thank you koppie, it works. It's dirty but it works :(

Is it the same with other editors ?

onepixelout

Sabino - October 17, 2009 - 01:32

I just cannot figure out how to use my favored onepixelout-player. After installing swftools the generic player does work.
There is a directory modules/swftools/onepixelout. I uploaded the stand-alone onepixelout-player to this directory. When I browse to "admin/settings/swftools/handling" I get the message "Missing 1pixelout/player.swf". I tried some variations about placing the files in different sub-directories and naming them 1pixelout and onepixelout but swftools still won't find the player. Is there any help for this problem?

See the installation instructions

Stuart Greenfield - October 17, 2009 - 11:07

This documentation has a table that gives the path and name needed for each player.

________

Just five more minutes...

www.stuartandnicola.com

solved

Sabino - October 17, 2009 - 14:20

Thanks.
1pixelout does work now.

swftools_get_media_url() issue ?

adVid - November 6, 2009 - 10:05

In config, I unset checking files and I'm using public file system.

If I write [swf file="test.swf"] then movie parameter is set to "http://www.domain.com/sites/default/files/".
Same behaviour if I write [swf file="/path/test.swf"] or [swf file="/sites/default/files/path/test.swf"].
"file" value is always omitted unless I set full path access to "test.swf".

What did I miss ??

Thank you.

Same problem

zapple - November 12, 2009 - 18:41

Hi,

I've got the same problem. Did you sort it?

Cheers
Zap

No. And it seems that nobody

adVid - November 14, 2009 - 13:06

No. And it seems that nobody care about this :(

I cannot seem to get this to

matthiasvanneste - November 16, 2009 - 17:36

I cannot seem to get this to work. I've set up SWF Tools to use SWFObject2 embedding, according to the swttools status report all ok. But when I add any of these snippets to a page it does not get replaced. I just get the code snippet in text on the page.

Any advice on what I'm doing wrong here ?

Many Thanks !

 
 

Drupal is a registered trademark of Dries Buytaert.