Author image
Senior Mind

Flash objects in Drupal

Its always the way, you go months without dealing with flash in Drupal when all of a sudden you get 5 people all asking the same thing, how do you deal with flash in Drupal.

We use the swftools module (, these excellent modules give you an easy way to embed flash objects in your Drupal site. We will cover the basics of adding flash content to your Drupal site below.

  1. Download swftools from ( Extract the module and put it into your sites/all/modules/ directory -
  2. Download the swfobject javascript from - put this in your sites/all/modules/swftools/shared so you should end up with a the actual javascript file on a path of /sites/all/modules/swftools/shared/swfobject/swfobject.js.... Swfobject provides some excellent javascript that gets around the IE7 'click to activate' issues. Luckily the swftools module will abstract all this for you.
  3. Log onto your Drupal site and goto admin/build/modules. Enable the following modules - Swftools, SwfTools integration and swfobject.
  4. Goto admin/settings/filters - click on the filtered HTML and enable the swftools filter, then do the same for the full HTML filter. THis will allow you to use the swftools filter command in your nodes.
  5. Goto admin/media/swf/embed, expand the javascript embedding section and enable the swfobject option - this will tell swftools to embed your flash objects using the swfobject javascript.

You are now ready to start adding flash (swf files) to your Drupal site. You have 2 options, you can either add the flash using a PHP function call (say in your theme, a block, or a PHP formatted node) or by using the filter in one of your full or filtered HTML nodes.

The PHP method.
This method is useful if you want to add a flash object to your Drupal theme, or perhaps embed a flash object into a block. The function call is very simple - something like print swf('mymovie.swf'); This will look for an swf file called mymovie.swf in your /files directory. You can get more advanced and pass additional paramaters into the swf function - the most typical being width and height, something like:

  print swf('mymovie.swf', array('height'=>100, 'width'=>400));

This method can be used in any of your theme files (for example page.tpl.php), or in any block or node so long as the input format is set to PHP

The filter method
The second option is to embed the flash using a filter tag, the format of this tag is simply <swf file="mymovie.swf"> - so long as you enabled the filters as per step 4 above you should be able to add this tag to any of your nodes or blocks and have the swf file embedded for you

There is plenty more to the swftools suite of modules, but hopefully that should get you started adding flash to your Drupal site


It should be noted that in-line scripts are not good for front-end performance. They block rendering of the page and downloading of additional components. You'd be better off with moving the script to an external file and using jQuery's document.ready or Drupal's Drupal.behaviors

For details about SWFObject (e.g., where to download and how to use the 'embedSWF' method), please check out and the section, 'How to embed Flash Player content using SWFObject dynamic publishing'.

how to add scrolling text in header,,,plz help me

man u saved my life, thats what I can say ..

Thanks for this gem. I was manually embedding my Flash content to a block and my blocks would reposition themselves all over the place.

I followed your methods and results were instant. Thanks a ton!

Step 5 is not working for me. the path "admin/media/swf/embed" does not work for me. Anyone can help?

Thank you for this tutorial. Very powerful, yet very easy to implement. Two thumbs up.

Thanks,It works perfectly...

t don't work for me.It say:Sorry, flash is not available.

Looks good, but how do you implement displaying a jpg if flash is disabled?

It don't work for me.It say:Sorry, flash is not available.

How can i add the Community features in Drupal. As i am new to Drupal. Please guide me for this. As i want to add boxing community details. Fro eg: who are playing boxing, how many titles they have won, etc

I'm not a programming wizard, so I hope someone else has encountered this problem, and may have a solution.

I also have a problem.Please help.


Please tell me how to add Flash to a block using FCK editor; I have flashnode module installed.

When I attach the file in FCK using the flash button it attaches but only the generic icon of flash appears in the FCK editor; where in the block a picture with a "x" mark appears.

I have tried using a fresh file and also by giving the address of a file already on server; like your suggestions!

I am able to create flash nodes as main content type!

Please also tell me how can I make main content (like story / blog etc) to appear in a block (not as a list or teasers using views) but as individual blocks!

Kindly suggest!


Sidra Kazmi


When I used the above mentioned method, working on my site "localhost", it worked perfectly, and I was happy to see how simple it was to add flash to blocks etc.

I then decided to move my site from "localhost" to an online domain using an .ftp program.
And the all of a sudden none of my .swf files seem to work.

All it says is:
"You are missing some Flash content that should appear here! Perhaps your browser cannot display it, or maybe it did not initialize correctly."

I'm not a programming wizard, so I hope someone else has encountered this problem, and may have a solution.

Hope, someone can help


Thanks for your code, i found this for a long time, you give me a big help.

I followed all of the steps and it appears like it should work, but all I am left with is a solid black area where the .swf should be playing. Any help would be appreciated.


Sounds like an issue with the flash itself maybe? Might be worth testing embedding the flash in some flat HTML just to make sure?

I can embed flash from other sites just fine, so maybe there is a problem with the way my .swf was exported.


Thanks for the great guide! I manage to run swf files in 10min

Can any one tell me how to embed a .swf file into a 'featured' block in Drupal template??

Thanks a lot!!!
Keep posting this great stuff.. :)

Step 5 tells us to go to admin/media/swf/embed , but when I go to that location , I get a 404 :/
has this something to do with newer versions of Drupal / swftools maybe ?

For the performance issues - performance could probably be improved if the scripts were tagged with a "defer='defer'" attribute...and for good measure, add settimeout/object-existence checking to make sure the code will run when it's all loaded properly.

Comments on this article are now closed, if you want to give us feeback you can use our contact form instead.