English General Social Software Technology Wikis & Wikipedia

embed flash into mediawiki

as noone seems to have documented this (at least i couldn’t find it) i’ll go for it:

how to embed flash (e.g. google video or youtube content) into mediawiki (based on MW 1.6.7, but should work in other versions, too)

i probably could have written a mediawiki extension but i’m too stupid for that. so we’ll have to live with a mediawiki hack. working example.

do the following:

  1. find the file Sanitizer.php in the folder /includes of your mediawiki installation
  2. find the function removeHTMLtags in that file. below that you’ll find a list of whitelisted HTML tags. add the tag embed to the list.
  3. find the function setupAttributeWhitelist in the same file. several lines below you will find HTML-attributes being whitelisted for each HTML tag. so you add a new line (maybe below the line that defines span):
    ’embed’ => array( ‘style’, ‘id’, ‘type’, ‘src’, ‘width’, ‘height’ ),

take care to replace the typographic ‘-quotes by straight ones when doing copy&paste. (wordpress converts the quotes on this blog, so you need to convert them back.)

you’re done. now you can copy the HTML-code provided by google or youtube into your wiki textbox and it’ll work. (make sure to make backups and document so you know what you’ve changed. when upgrading you’ll have to repeat the process. no warranties for possibile security leaks resulting from the hack.)

update april 2007: i just tested, this hack also works with mediawiki 1.9.2, just that you need to add embed to $htmlpairs. (note: in case the embed-code you want to use has the format <embed /> you now have to convert it to <embed> </embed> before posting it to your wiki.) i also would recommend to paste the last line of code near br instead of span (the file has got rearranged a bit).

23 replies on “embed flash into mediawiki”

Works for me in mediawiki 1.10.0 too. I changed it a bit though, so that I could use google calendar (iframe tag):

diff includes/Sanitizer.php.hack includes/Sanitizer.php.bak

‘ruby’, ‘rt’ , ‘rb’ , ‘rp’, ‘p’, ‘span’, ‘u’

array_merge( $common, array( ‘align’, ‘longdesc’, ‘marginheight’, ‘marginwidth’, ‘name’, ‘src’, ‘style’, ‘width’, ‘height’, ‘frameborder’, ‘scrolling’ ) ),

Looks like your sanitizer didn’t like my diff. The changes I made were:

ruby, rt, rb, rp, p, span, u, iframe

iframe => array_merge( $common, array( align, longdesc, marginheight, marginwidth, name, src, style, width, height, frameborder, scrolling ) ),

Tried your code, and it works fine for my page ‘preview’. But when I save the page, the object doesn’t load properly (or at all). Any ideas?

I didn’t get this issue at all.

What version of mediawiki are you running? We’ve only confirmed it works on versions upto 1.10.1 – I’m not familiar with some of the features of 1.11.x, maybe it does some kind of pre-caching differently?

The only issue I saw was that firefox warns me about unencrypted content (my wiki is over ssl, but the objects I’m importing aren’t). Not really a big problem.

Hi There. thanks allot for your code – it worked (almost) great.
The only problem is that the video is displayed in a very small frame size, and it doesn’t seem to change when I change the parameters.

Another small update, is that for youtube code, I added the tags: ‘name’,’value’,’wmode’
’embed’ => array( ‘style’, ‘id’, ‘type’, ‘src’, ‘width’, ‘height’, ‘name’,’value’,’wmode’ ),

And also, the same thing you advice for “embed”,
I did for the tags:

Hope it’ll help someone.


i do your codes step by step. but i dont know how can i add a link to my media wiki.
should i use only the link of that video or i should add extra things to its link.
plz mail me my answer.

thanks for your codes dear.
it doesnt work in mediawiki 1.11.0.
do you know why?
and how can i show a teacher tube and you tube video in media wiki 1.11.0 ?


So this embedded the flash content but failed to pass the flashvars to the swf when using the object param method.

I whitelisted the object and param tags and the attributes for both tags like so..

‘object’ => array( ‘type’, ‘data’, ‘id’, ‘width’, ‘height’ )
‘param’ => array( ‘name’, ‘value’ )

Seems to ignore the params

How do you embed various kinds of sources, for instance just another html-page with som javascript in it?. I miss a description of the different pameters. What is the correct format, and what are the options?
I have tried to do some experiments, but so far nothing has worked. Please give a practical example of the use.

Great solution. I spent some time and grief before finding your instructions. A few minutes later and voila.

Danke Herr Fahrnberger.

hi there, good day…

I’ve successfully followed your guide, but when i hit the save button on the mediawiki with the fckeditor, the embed tag doesn’t show, which is correct. but the problem is the movie doesn’t load…

and when i right click on the movie area, it show “movie not loaded”…

any help?? badly needed.. .thanks in advance

Comments are closed.