Wiki

Embedding YouTube Video in Wiki activity?

 
Picture of John Patten
Embedding YouTube Video in Wiki activity?
 
Anyone have a solution to embedding YouTube videos into the Wiki activity? Everything seems to work great, can even see the video when in edit mode on wiki page, however the minute you save your changes and view the actual wiki page the YouTube video turns into a white block.

TIA!
 
Average of ratings: -
Picture of Amir Elion
Re: Embedding YouTube Video in Wiki activity?
Translators

This might be related to the embedding code you use and some flash parameters you define there. I had to play around with some parameters to get my flash object working on the html editor. Not sure this is the case in the wiki modukle as well.

Does this work when you try to embed the object in a regular HTML page on moodle.

 
Average of ratings: -
Picture of John Patten
Re: Embedding YouTube Video in Wiki activity?
 
Hi Amir...

Yup, works fine on the center activity. Appears to be only an issue within the Wiki activity.
 
Average of ratings: -
Picture of Nadav Kavalerchik
Re: Embedding YouTube Video in Wiki activity?
Core developersParticularly helpful MoodlersPlugin developersTestersTranslators
what kind of wiki do you use ? (the standard one or nwiki2)

do you have access to the code ?
so you can check something for me...
like... that you filter out swf files with format_text() function ?

look for something like :
format_text($this->content, FORMAT_HTML);

i had this issue on several places (3rd party plugins)

 
Average of ratings: -
Picture of Nadav Kavalerchik
Re: Embedding YouTube Video in Wiki activity?
Core developersParticularly helpful MoodlersPlugin developersTestersTranslators
btw.

here is a link to a patch that adds a new "insert embed" button
to the toolbar of the internal "HTML Area" editor (moodle versions 1.9.x)
http://tracker.moodle.org/browse/MDL-20363

enjoy smile
 
Average of ratings: -
Me
Re: Embedding YouTube Video in Wiki activity?
 
I managed to solve the problem of embedding YouTube in to wikis by installing the MultiMove Filter. It can be found here.
Hope that helps.
 
Average of ratings: -
Me
Re: Embedding YouTube Video in Wiki activity?
 
This has become temperamental again within wiki. Some videos embed fine and others don't show at all when the page is saved. Furthermore it now will not allow standard hyperlinks to youtube videos to work. Can anyone give me any advice on this? These glitches are really affecting the students' work.
 
Average of ratings: -
paula
Re: Embedding YouTube Video in Wiki activity?
Particularly helpful Moodlers
We had a similar problem with You Tube in other areas of Moodle.  Found out it had been filtered out with the district filtering software.
 
Average of ratings: -
Picture of Glenys Hanson
Re: Embedding YouTube Video in Wiki activity?
 
Hi everyone,

I've had no trouble inserting YouTube and similar videos into OUwiki in the same way as I do in the other HTMLarea editors (forums, Glossaries, Blogs...) on Moodle:
  1. Copy the URL of the video (not the embed code) on YouTube
  2. In the text editor in Ouwiki, write a word (any word, it won't be visible later),
  3. Select the word,
  4. Click on the link icon in the toolbar,
  5. Paste in the URL of the video, click on OK
  6. You'll see your word has become a link but you won't see the video until you ...
  7. Click on Save changes.
Here's a step-by-step tutorial with screenshots: Ajouter_une_video.pdf It's in French but with the above it should be clear.

Cheers,
Glenys
 
Average of ratings: Useful (1)
Picture of Victor Santos
Re: Embedding YouTube Video in Wiki activity?
 
Hi.

Those steps just don't work for me in the Wiki or OuWiki activities, but work fine on other html areas like you said.

thoughtful


 
Average of ratings: -
Picture of Chris Sherman
Re: Embedding YouTube Video in Wiki activity?
 
Glenys,

This work around doesn't work on my Moodle account either. Is there some setting in the Adminstration area that I need to change?
 
Average of ratings: -
Picture of Denis Jacquest
Re: Embedding YouTube Video in Wiki activity?
 
Hello,

this problem is related to the filtering capacities of the moodle code.

It's just erasing your <iframe> tag or whatever your using to embed video.

to solve the <iframe> filtering of moodle :

Just add <iframe> in the allowed tag list in moodle/lib/weblib.php about line 88
http://moodle.org/mod/forum/discuss.php?d=138083

now I'm able to embed an iframe in wiki or database and probably others activities.

Be sure of knowing what you're doing with this small hack, it's not very safe to do that, that's why moodle is filtering this type of tag... but it's work.

Denis

 
Average of ratings: -
Paul
Re: Embedding YouTube Video in Wiki activity?
 

A couple follow-up questions:

We recently upgraded to Moodle 2.0.  We would like to embed glogster pages in our student wikis (projects).

The embed codes are all iframes.

  • Is the safety issue with iframes in wikis a security issue or a problem that I might mess something up if I edit moodle/lib/weblib.php (around line 88)
  • Does this hack still work in v. 2.0?
  • It appears that there are 3 different wiki versions.  Do they deal with iframes differently?
  • Is there a non-iframe way to embed these files that wouldn't require this hack?

An example of the embed code would be:

<iframe src= "url of glog here" width="960" height="1300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" style="overflow: hidden;"></iframe>

 

Thanks

 
Average of ratings: -
Picture of Glenys Hanson
Re: Embedding YouTube Video in Wiki activity?
 
Hi Chris,

Yes, in Site Administration > Modules > Filters > Manage filters enable Mutlitmedia Plugins.

Cheers,
Glenys

 
Average of ratings: -
Picture of ViliMaka Foliaki
Re: Embedding YouTube Video in Wiki activity?
 
Same problem with the Journal - YouTube videos cannot be embedded; you can only hyperlink them.


 
Average of ratings: -
Picture of John White
Re: Embedding YouTube Video in Wiki activity?
 

See further down...

 
Average of ratings: -
Me
Re: Embedding YouTube Video in Wiki activity?
 

Has anyone found a solution to this yet? I have tried all the solutions and there is no change. The video is displayed in the editor but does not appear when previewed and saved.

 
Average of ratings: -
Picture of Franco Chiavetta
Re: Embedding YouTube Video in Wiki activity?
 

It is possible i have found where the error occurs?

Editing the file ../mod/wiki/ewiki/ewiki.php

and changing the line n. 729 from:
$o .= $ewiki_plugins["render"][0] ($data["content"], $render_args);

to:

$o .=  $data["content"];

works in my environment.

Is this a step toward a workaround?

 
Average of ratings: -
Picture of John White
Re: Embedding YouTube Video in Wiki activity?
 

Hi All,

Reading through this thread, this appears to be a pretty vexed issue that has not yet gone away! It certainly appears to be the case that in Moodle 2.0(.1) YouTube videos are handled differently inside a wiki to the way they are handled in a course topic or similar general location.

In a course topic the whole object/embed content (or even the iframe) copied from youtube's embed panel can be pasted into the html editor, saved and displayed as a video. This object takes its size and settings from the copied code, and so even 3D glasses options will work INSIDE moodle without the need to link out.

Of course, you cannot paste such content in at all if object/embed code is specifically outlawed in...

Admin -> Security -> Site Policies    'Allow EMBED and OBJECT tags' = No

unless also in the same site policies 'Enable trusted content' = Yes,

AND the user's role settings say their content will be trusted!

More strictly, you can paste it in, but you find it remove or deactivated. But aside from these permissions issues, this embedding method of getting youtube content into a topic works a treat!

In the wiki, however, we do not seem to be playing by the same rules! This may well be forced onto the situation by the notion of the wiki being a collaborative activity (generally speaking), so if you can't 'trust' the content from one user, how can you trust the content from another! If this is the view taken, which seems likely, then object/embed & iframe entries pose a security risk (or at least the risk of unacceptable content), and these get removed even if you are a trusted being! So what about using other possible routes?

Yes, you can enable the Multimedia plugin filter for youtube videos and that works consistantly inside and outside a wiki. As we know, this means that if you enter some text, highlight it, click the hyperlink button, and then paste in the url of the video. Such as:  youtube.com/watch?v=0GcLW0g_c1s. Note however, that this url needs to be take from youtube's 'share' panel, not the 'embed panel' because they are quite different. The 'share' version works with the filter, whereas the embed version youtube.com/embed/0GcLW0g_c1s does not! This is simply because the filter is looking for ?v= in the url, and in the latter version it isn't gong to find it! [note I've had to cut the http etc to stop this link linking!!!]

So for moodle to behave consistantly we need to be consistant too. And there is obviously room for confusion here.

There is also a method involving the use of a [youtube] tag each side of the url, as explained here: http://docs.moodle.org/en/Multimedia_plugins#YouTube_Link_Filter

but I'm still not clear as to how that is different from simply using the media filter described above.

However, the multimedia filter may solve one problem, but it creates another. Elsewhere it has been explained that you can change the size of the display in some types of media by trailing it with d=400x300 (or similar), but the youtube instance of the filter strips these out. in fact it strips out all the content after the ? except the v=#### video reference. This means that using the multimedia filter to give youtube content results in a loss of control of the size of the video in the wiki, and leaves out all the options (such as the colour of your 3D glasses)!

So we appear to have away to go on this as yet.

Regards,

John

 
Average of ratings: Useful (1)
Picture of Ravi Murugesan
Re: Embedding YouTube Video in Wiki activity?
 

The default embedding code provided by YouTube is now with the iframe tag, not the object or embed tag.

The iframe tag to embed videos works in a label or page in Moodle, but not in the wiki.

After following the above suggestions from John, I embedded a YouTube video using the object tag.

For example:

<object data="

" type="application/x-shockwave-flash" height="400" width="600"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="allowFullScreen" value="true" /></object>

Then it worked for me smile

To learn more about these tags, see http://www.w3schools.com/html/html_youtube.asp

 
Average of ratings: Useful (1)
Picture of John White
Re: Embedding YouTube Video in Wiki activity?
 

Having thought about this a bit more, I think Franco's solution above may work but will have unintended consequences (such as switching off filtering you want left on).

So I have set about finding a fix for the underlying problems.

Firstly, not being able to supply dimensions to the youtube filter the way you can to Quicktime or Flash video. This only really requires a few changes to the file /filter/mediaplugin/filter.php

We find the line

if (!empty($CFG->filter_mediaplugin_enable_youtube)) {

and make changes as highlighted (copy and paste, but only in a proper HTML editor, eg Smultron, Fraise, Ultraedit)

if (!empty($CFG->filter_mediaplugin_enable_youtube)) {
//see MDL-23903 for description of recent changes to this regex
//$search = '/<a.*?href="([^<]*)youtube.com\/watch\?v=([^"]*)"[^>]*>(.*?)<\/a>/is';
$search = '/<a[^>]*href="([^<]*?)youtube.com\/watch\?v=([^&"]*)(&amp;d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>(.*?)<\/a>/is';
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_callback', $newtext);
$search = '/<a[^>]*href="([^<]*)youtube.com\/v\/([^"\?]*)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>(.*?)<\/a>/is';
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_callback', $newtext);
}

Then we find the callback function filter_mediaplugin_youtube_callback and make these changes...

function filter_mediaplugin_youtube_callback($link, $autostart=false) {

$site = addslashes_js($link[1]);
$url = addslashes_js($link[2]);
$info = addslashes_js(strip_tags($link[3]));//strip out html tags as they won't work in the title attribute
if (empty($link[4]) or empty($link[5])) {
$size = 'width="425" height="344"';
} else {
$size = 'width="'.$link[4].'" height="'.$link[5].'"';
}

return '<object title="'.$info.'"
class="mediaplugin mediaplugin_youtube" type="application/x-shockwave-flash"
data="'.$site.'youtube.com/v/'.$url.'&amp;fs=1&amp;rel=0" '.$size.'>'.
'<param name="movie" value="'.$site.'youtube.com/v/'.$url.'&amp;fs=1&amp;rel=0" />'.
'<param name="FlashVars" value="playerMode=embedded" />'.
'<param name="wmode" value="transparent" />'.
'<param name="allowFullScreen" value="true" />'.
'</object>';
}

This should allow dimensions to but put in either in the form

http:// www .youtube.com/watch?v=6RFuRY7azgA&d=450x300

or

http:// www .youtube.com/v/6RFuRY7azgA?d=450x300

Note thank this depends entirely on the url you get from 'share' in youtube!

Finally we can also get Moodle to do the work on putting in an iframe that users are generally blocked from (along with object and embed). My reasoning here is that it must be safe for moodle to do in the say way as it embeds to object safely for you!


Here we add an extra trap in the filtering process inside the same braces as before (top of this post)

$search = '/<a[^>]*href="([^<]*)youtube.com\/embed\/([^"\?]*)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>(.*?)<\/a>/is';
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_embed_callback', $newtext);

Note this adds a NEW function call so them we add a new callback function (below the current youtube one)

/**
* Change links to embedding Youtube content into iframe Youtube videos
*/
function filter_mediaplugin_youtube_embed_callback($link, $autostart=false) {

$site = addslashes_js($link[1]);
$url = addslashes_js($link[2]);
$info = addslashes_js(strip_tags($link[3]));//strip out html tags as they won't work in the title attribute
if (empty($link[4]) or empty($link[5])) {
$size = 'width="640" height="390"';
} else {
$size = 'width="'.$link[4].'" height="'.$link[5].'"';
}

return '<iframe title="YouTube video player" class="youtube-player" type="text/html" '.
'src="'.$site.'youtube.com/embed/'.$url.'" '.
'frameborder="0" '.$size.'>'.
'</iframe>';
}

And THIS allows you to use the youtube embed content, BUT WITHOUT THE IFRAME STUFF ARROUND IT. Like so:

http:// www .youtube.com/embed/6RFuRY7azgA

And add dimensions, like so:

http:// www .youtube.com/embed/6RFuRY7azgA?d=640x390

I've tested this moderately well though only on Firefox.

Thats all for now.

John

[note: I have inserted a couple of spaces in urls to stop them linking! - there must be a better way?]

 
Average of ratings: -
Me
Re: Embedding YouTube Video in Wiki activity?
 

I don't know if this will help anyone but it started working for me (in 1.9.10) when I disabled CamelCase linking.

 
Average of ratings: -
Picture of D Vass
Re: Embedding YouTube Video in Wiki activity?
 

Yes! Thank you! This helped me! I have been adding videos to a wiki that my pupils have been creating about our lessons. The first one was added as a simple link (to the video file uploaded in the file area of the course) and it worked! But then any subsequent links were not showing. Disabling the Camel Case links works wonders-I can now see all videos!

Phew! I was getting a bit worried when seeing all the technical changes mentioned in the previous posts. Thanks Ruth!

 
Average of ratings: -
Picture of Javier Oteiza
Re: Embedding YouTube Video in Wiki activity?
 

Hi D Vass,

 

Will you please explain how I can disable Camel Case links?

 

Thanks

 
Average of ratings: -
Picture of Nathan Hammond
Re: Embedding YouTube Video in Wiki activity?
 
3 years later and there still is no progress on this...from what it appears to me anyway. Is there a replacement Wiki that works with embedding? What can be done to help this get addressed? What about embedding other (non youtube code)?
 
Average of ratings: -
Picture of Toni Roberts
Re: Embedding YouTube Video in Wiki activity?
 

In Moodle 2.5, I too am having the same problem. Any suggestions for correction?

Thanks,

Toni

 
Average of ratings: -
Joe Boyle
Re: Embedding YouTube Video in Wiki activity?
 

Hey all,

This drove me nuts- I knew how to embed code and it works great on pages and labels, however this is the missing piece when I tried to embed video code in a glossary:

  • For security reasonsiframe code is not allowed in Moodle activities to which all class members can contribute, including Assignment submissions, WikiForumDatabase andGlossary activities. In these activities iframe-embedded video displays in the HTML editor, but will be stripped out when posts or submissions are saved.

Found on UMass Amherst site https://www.it.umass.edu/support/moodle/embed-video-or-audio-a-moodle-page#Embed Media Using iFrame Code (Instructors Only)

Joe


 
Average of ratings: -
Picture of Andreas Schenkel
Re: Embedding YouTube Video in Wiki activity?
Particularly helpful Moodlers

So embedding of youtube into  wiki is not possible.


Is it possible to use a normal link to a youtube-video and the moodle-filter converts the link into an embeded video?

 
Average of ratings: -