Google this site (~ 2000 pages):

Home
RSS Feed RSS Feed

« Previous: email spam dissected | Next: barcamp vienna »


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).


 

« Previous: email spam dissected | Next: barcamp vienna »

23 Comments
#19942 Pascal Rauma, Finland says on November 30, 2007 at 9:16 pm
Avatar
top

I just used your code and it worked. It only took me 5mn. Thank you very much.

bottom
#25920 Wilma says on December 26, 2007 at 12:18 am
Avatar
top

Thanks. I used your code for MediaWiki 1.10.1 and it works. I also managed to embed Blip TV files.

bottom
#26619 James, UK says on December 28, 2007 at 4:29 pm
Avatar
top

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’ ) ),

bottom
#26620 James, UK says on December 28, 2007 at 4:33 pm
Avatar
top

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 ) ),

bottom
#29579 Swapnil says on January 9, 2008 at 4:55 pm
Avatar
top

This is a great thing. I have been dying to get this information. Many thanks for your tips !

bottom
#36821 Federico Pistono says on January 30, 2008 at 11:39 am
Avatar
top

That was REALLY helpful. Works with blip.tv perfectly, just add new elements to the array and you’ll be good to go.

Thank you very much again.

bottom
#37104 jacob says on January 31, 2008 at 12:50 am
Avatar
top

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?

bottom
#37225 James, UK says on January 31, 2008 at 1:09 pm
Avatar
top

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.

bottom
#42805 LGC Metablog » Blog Archive » Embedding video in MediaWiki says on February 21, 2008 at 11:43 am
Avatar
top

[…] Instructions (with thanks to Helge) […]

bottom
#44810 tal galili says on March 1, 2008 at 1:32 pm
Avatar
top

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’
to:
’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:
param
and
object

Hope it’ll help someone.

Tal.

bottom
#48161 mahdi says on March 18, 2008 at 11:16 am
Avatar
top

hi
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.

bottom
#48200 Helge says on March 18, 2008 at 3:36 pm
Avatar
top

@mahdi: You use the entire “embed”-code supplied by (for example) youtube.

bottom
#48611 Daniel says on March 21, 2008 at 5:47 am
#51480 mahdi says on April 6, 2008 at 9:17 am
Avatar
top

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 ?

thanks.

bottom
#69276 hyun-soo, Kim says on July 19, 2008 at 9:33 am
Avatar
top

it works!!! thanks.

bottom
#84111 Todd says on August 27, 2008 at 1:03 am
Avatar
top

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

bottom
#102580 Mike Benton says on September 26, 2008 at 9:44 pm
Avatar
top

Awesome trick, concise how-to. Thank you very much now we can embed videos about the Shadow and G1 in our wiki!

Thanks!

bottom
#118373 rene says on December 5, 2008 at 6:57 pm
Avatar
top

Thank you very much for the tip , it worked great for me.

bottom
#128429 neingeist says on January 11, 2009 at 2:56 am
Avatar
top

here’s a patch for mediawiki 1.13.x:

http://entropia.de/wiki/Entropia:Flash_einbetten

+++ neingeist

bottom
#205692 Søren Blaabjerg says on January 3, 2010 at 4:24 pm
Avatar
top

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.

bottom
#212602 doug says on March 12, 2010 at 12:59 am
Avatar
top

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

Danke Herr Fahrnberger.

bottom
#225815 Trev says on July 15, 2010 at 5:21 am
Avatar
top

Thanks for that! Very helpful.

bottom
#226608 zplits says on July 25, 2010 at 1:02 pm
Avatar
top

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

bottom

Sorry, the comment form is closed at this time.

corner