Issue with iframes and embedding media

Issue with iframes and embedding media

by James Cracknell -
Number of replies: 21

Hi

The code I have is this.  It works in the HTML editor - but as soon as it is saved it just messes up. 

What is wrong with this code?

<iframe id="cc-embed" src="http://www.commoncraft.com/embed/b18470e95f?width=640&height=360&autoplay=false&playbutton=true&controls_visible=false&end_video_behavior=default" width="640" height="360" frameborder="0" scrolling="false" ></iframe>

Average of ratings: -
In reply to James Cracknell

Re: Issue with iframes and embedding media

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Do you have multimedia settings set correctly? Not sure if there is a correlation there, but that would be the first place to start.  

In reply to James Cracknell

Re: Issue with iframes and embedding media

by Mauno Korpelainen -

Nothing wrong in the code itself - moodle just does not allow you to use iframes everywhere. Administration menu has a couple of settings for controlling trusted content but those settings are mostly for giving students (all users) free hands to use trusted content. If you allow adding iframes you allow at the same time iframe based attacks - so it's a security issue.

If you are an administrator or teacher you should be able to use iframes in such activities, labels, etc that students are not allowed to use ( try for example topic index or some course label )

Moodle ( weblib.php / $ALLOWED_TAGS ) removes iframe tags automatically from forums, blogs, user profiles and so on - from all users.

Average of ratings: Useful (4)
In reply to Mauno Korpelainen

Re: Issue with iframes and embedding media

by Lynn Scarlet Clark -
Hello - your code looks ok (if a bit busy) - can I ask how you put the code in? You said the HTML editor: this may be your problem. For a Simple iframe it would normally be ok to just switch to HTML in the tiny MCE editor, but I think that may not be right for you. You should try turning off the HTML editor in your profile settings (you can turn it back on later). Go to your profile and then choose the edit tab. Ensure advance options is on and then look for the 'when editing text' option and select use standard webform. Go back and retry to insert your code. If this doesn't work I'm sure we'll work out what it is.
In reply to Mauno Korpelainen

Re: Issue with iframes and embedding media

by James Cracknell -

Hi

Is there anyway that Admins can be given permissions to use iframe tags and it is removed for all other users (just need it for forums really).

thanks

James

In reply to James Cracknell

Re: Issue with iframes and embedding media

by Mauno Korpelainen -

No - unless if you start hacking the code of forum module...

Have you tried to use object tags instead of iframes:

<object type="text/html" data="http://www.commoncraft.com/embed/b18470e95f?width=640&height=360&autoplay=false&playbutton=true&controls_visible=false&end_video_behavior=default" style="height:360px;width:640px;border:0;overflow:hidden"></object>

Edit: ...but you obviously need to check also settings Allow EMBED and OBJECT tags and Enable trusted content from Security > Site policies to view those object tags... which is not really good option mixed

If you could use the mov file inside the inframe directly you could add a link to the mov file and use multimedia filter to show the file directly.

Average of ratings: Useful (1)
In reply to Mauno Korpelainen

Re: Issue with iframes and embedding media

by Nadav Kavalerchik -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

Wooow ! thanks Mauno! i was not aware of the <object type="text/html">...</object> "trick"

Just tried it on Moodle 2 course resource and it works fine.

I am running to tell the Teachers that we do not need to hack the code. (like i did on some other system) 

Thanks smile

In reply to Nadav Kavalerchik

Re: Issue with iframes and embedding media

by Wesley Grimes -

I have the same issue.  I'm trying to embed a Vimeo video into a database.  I'm trying to create a database that has about 50 short (5 minutes or so) tutorial videos.  I want my users to be able to search the videos with keywords and then watch the videos.

I have tried to recommendations presented here, but I don't know html well enough to understand what I'm doing wrong.  Here is what I'm trying to embed.

<iframe src="http://player.vimeo.com/video/34668579?title=0&amp;byline=0&amp;portrait=0" width="400" height="300" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe><p>Navigating HVE - Part 6 from <a href="http://vimeo.com/accidentrecononline">Wesley Grimes</a> on <a href="http://vimeo.com">Vimeo</a>.</p>

I tried just taking my video reference and substituting it into the <object type..> example above but that did not work....I got a blank/white box....no video, no controls, etc.  

I then figured out that I need to change the type to video/mp4....that did not work.

I'm stumped.

In reply to Wesley Grimes

Re: Issue with iframes and embedding media

by Mauno Korpelainen -

Wesley,

you did not mention the version of your moodle but I suppose you are using moodle 2.

You don't need iframes or not even object tags to embed Vimeo videos to moodle - moodle has a multimedia plugins filter for that purpose, you just need to enable Vimeo from settings of multimedia plugins filter.

Go to Site administration > Plugins > Filters > Manage filters > Enable Multimedia plugins filter and on the right side of that filter select Settings and Check Vimeo. Click Save changes.

Now when you add any Vimeo link to your site multimedia filter changes that link to correct tags.

For example link to  plays then automatically

If you want to use object tags for such content that can't be played with multimedia plugins filter you need to know the correct path of that video file or html file that has video file embedded and use correct html in object tags - and object tags can't be used in such activities that students are allowed to use (trusted content) without changing site policy (to allow object tags everywhere. So the best option is to use multimedia plugins filter.

Average of ratings: Useful (1)
In reply to Mauno Korpelainen

Re: Issue with iframes and embedding media

by Annali Nicolaou -

Thank you so much!!!!!


This was a VERY useful answer, and solved a huge problem for me.



In reply to Mauno Korpelainen

Re: Issue with iframes and embedding media

by Dan Trockman -
Using moodle 2.5 and having the same issues and have lifted the restrictions. Behavior is different depending on the module unfortunately, should be consistent throughout moodle, especially in moodle 2.

Embeding videos from google drive worked for me both ways below but students are expecting to embed video in a workshop and cannot. They can see it previewed in the editor but will not show when not editing!

We will try the object version as pasted below.

In reply to Mauno Korpelainen

Re: Issue with iframes and embedding media

by Annali Nicolaou -

Hi,


I have researched this topic to death now, and your solution was the ONLY one that worked, however, I see you linked your file to a file on https://www.commoncraft.com/.


I was hoping you could help me get this code right, but to point it to a .mp4 file located on a local server?


Any help would be greatly appreciated, I am completely stumped!


Thank you!

Annali

In reply to Mauno Korpelainen

Re: Issue with iframes and embedding media

by Greg Padberg -

Is there a definitive mention somewhere on which areas Moodle does not allow usage of iframes?

Discovering this behavior was a mystery to me and there was not much explanation available for it outside of this discussion thread.  I feel this should be mentioned somewhere in the documentation.

https://docs.moodle.org/27/en/Iframe

In reply to Greg Padberg

Re: Issue with iframes and embedding media

by Greg Padberg -

OK, so I took a swing at updating the documentation to add the following:

For security reasons, moodle just does not allow you to use iframes everywhere. In general, iframe code is not allowed in Moodle activities to which all class members can contribute, including Assignment submissions, Wiki, Forum, Database, Glossary, and Blog activities. In these activities iframe-embedded video displays in the HTML editor, but will be stripped out when posts or submissions are saved.

https://docs.moodle.org/27/en/Iframe


Average of ratings: Useful (1)
In reply to James Cracknell

Re: Issue with iframes and embedding media

by Nadav Kavalerchik -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

There is a workaround for this issue, though, I think we should not filter out iframe in Moodle or at least have a setting for that for the administrator to decide. (like we have for OBJECT html tag)

Anyways...

You can use:

<object type="text/html" data="http://www.commoncraft.com/embed/b18470e95f?width=640&height=360&autoplay=false&playbutton=true&controls_visible=false&end_video_behavior=default" style="height: 360px; width: 640px; border: 0; overflow: hidden;"  id="cc-embed" ></object>

In reply to Nadav Kavalerchik

Re: Issue with iframes and embedding media

by Wesley Grimes -

I finally got it to work by using 'old' embed code.  On Vimeo you can click a button on the top of the embed dialog to generate 'old' embedding code....using <object> tags.

That works.....EXCEPT......

I am posting these in a database, it works except that I can not play it full screen.  When I press the full screen button on the embedded player, nothing happes.  If I hit right-click, it shows the option of "exiting full screen", so I think the player is sending the full-screen command, but moodle is somehow blocking it.

I"m in Moodle 2, running this at moodlerooms.com

Thx for the advice, I really appreciate the help I have recieved here.

In reply to Wesley Grimes

Re: Issue with iframes and embedding media

by claire gerrard -

Please help...please....

I am having very similar issues trying to embed YouTube content to the autentication>manage authentication> "instructions" field section of the Login page.Despite allowing object and embed tags and setting the multimedia filters to "on" and enabling youtube these are the following :

1. iframe is fully functional i.e. video displays/screen maximises in the tinymce editor but will not display at all on the login page.

2. Tried object tags. Going well until- on the login page even though the video plays the MAXIMISE button doesn't work.

3.Although the least of my worries, but the info may help- the tinymce "moodle media" button is completely empty accept the titles "general" etc but nothing is displayed inside.

So i thought maybe i have messed something up somewhere during customisation, so i will see what happens if I use a clean reinstall (i.e. none of my data, default settings except for enabling the multimedia, object/embed and youtube) and try the same thing-But it does exactly the same thing.

What is going on ???

Your reply would be greatly appreciated smile

 (using moodle version Moodle 2.5.2)

In reply to Nadav Kavalerchik

Re: Issue with iframes and embedding media

by Glenn Pillsbury -

Same issue here.  <iframe> displays correctly in the TinyMCE editor but the "src" is stripped out of the saved page.  Deciding to forbid <iframe> in Moodle is one thing, but allowing it in the HTML editor is an inconsistency that should be addressed.

Also, the <object type> trick didn't work for me when used with a Vimeo video (I know about the filter).

Moodle 2.1.2

In reply to James Cracknell

Re: Issue with iframes and embedding media

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Claire,

To display a youtube video it should not be necessary to use an iframe or anything very fancy. Just enable the YouTube repository and select the video from there. The multimedia plugins filter should then display it for you.

The information in this discussion here might be helpful if you need to get technical, but I suspect that you don't.

https://tracker.moodle.org/browse/MDL-31732

 

In reply to Justin Hunt

Re: Issue with iframes and embedding media

by K Kirkwood -
I was hoping to integrate Timeline JS into my class Moodle, but to do so I the students need to be able to paste in some code, e.g., 


<iframe src='http://cdn.knightlab.com/libs/timeline/latest/embed/index.html?source=0Ahr2x3VUZPVVdFc0NzJBOWpLMXVNbUNhOFBCSjlyRmc&font=Bevan-PotanoSans&maptype=toner&lang=en&height=650' width='100%' height='650' frameborder='0'></iframe>

(I also pasted it into the html here...just checked and it went poof here too).


I tried wiki and forum, but as soon as you save the code the code goes poof, and you get a blank page


I tried the <object> trick, no go. I gather there is something I can request of my admin to open this up to my students or not? [Moodle 2.6]


Thanks

In reply to K Kirkwood

Re: Issue with iframes and embedding media

by K Kirkwood -

Same issue with <iframes>  from embedded Google maps (trying to make a glossary with the kids with their linked maps. Works for me to embed an <iframe> but not for the kids in the glossary proper. 

In reply to K Kirkwood

Re: Issue with iframes and embedding media

by Ingrid DSouza -

Hi, 

Similar issues using iframes and object type as suggested.

I totally understand that using iframes pose a security risk but for people (students/teachers) with no admin access this is a big issue!

Unfortunately our team has chosen NOT to turn on the Multi-media repository so that is yet another issue!

Information - Moodle 2.4.x and embedding in a forum post (seems to work in all other activities or resources e.g. book/page) but as these users don't have access to edit functionality it is a BIG issue.

Any ideas?


HELP


Ingrid