ruby on rails - How to upload vimeo videos using Media plugin (and not HTML option) -


i'm working on ruby on rails 2.3.8 , last version of rails tinymce plugin.

i users have ability of adding kind of videos text editor. it's now, can add youtube videos, , can upload them computer.

the problem vimeo videos don't create common html <object> code, create iframe them, , if try import 1 of them using media plugin, i'll have paste video example: http://vimeo.com/16430948, , generate following html (which won't work):

<object width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"> <param value="http://vimeo.com/16430948" name="src"><embed width="100" height="100" type="application/x-shockwave-flash" src="http://vimeo.com/16430948"> </object> 

while vimeo videos need following html being displayed:

<p><iframe frameborder="0" height="225" src="http://player.vimeo.com/video/16430948" width="400"></iframe></p> <p> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="100" width="100"> <param name="src" value="http://vimeo.com/16430948" /><embed src="http://vimeo.com/16430948" width="100" height="100" type="application/x-shockwave-flash"></embed> </object> 

now, which difference between 2 generated html? it's iframe missing in first code i've posted, doesn't work.

so, question is: how add iframe tinymce programmability it's automatically added when vimeo video embedded?

well, should write own plugin (it pretty simple) check changes user made. when user entered vimeo link grab relevant content editor , put new element (an iframe).

your code should (you have modify it, sure right direction):

// may choose other event check ed.onchange.add(function(ed){    var body = ed.getbody();    // check vimeo using jquery object   $(body).find('param').each(function(index, element){     // vimeo adress found in value     if (this.value.search('http://vimeo.com') == -1) return;     var node = this;     var iframe_not_parent = 1;         while(node.nodename !== 'body'){       node = node.parentnode;       if (node.nodename !== 'iframe'){         iframe_not_parent = 0;          break;       }     }      // ok, vimeo thing not inside iframe - put inside     if (iframe_not_parent){          with(document.getelementbyid(iframe_id).contentwindow){                    var new_iframe = document.createelement("iframe");           this.parentnode.parentnode.append(new_iframe);           new_iframe.append(this.parentnode);         }     }   }); }); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -