Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

embed youtube

edited October 2006 in Vanilla 1.0 Help
is there any extension that allows youtube videos to be posted in my vanilla forum?
«1

Comments

  • i think object and embed tags are stripped. All you have to do is allow them. In Sirnot's html formatter there is this code
    $Html_DisallowedTags = array('link', 'iframe', 'frame', 'frameset', 'object', 'embed', 'style', 'applet', 'meta');

    remove object and embed from it
  • edited October 2006
    Don't allow these tags. here is a solution, it is for the BBcode parser, but it could work with any formatter: http://lussumo.com/community/discussion/2199/#Item_44 (read the following post too)
  • edited October 2006
    Yeah, the important line is

    $String = preg_replace('/\<youtube\>(.+?)\<\/youtube\>/', '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>', $String);
  • edited October 2006
    thanks everyone for the posts. I downloaded and tweaked better bbcode as suggested above. but despite clicking the bbcode button below my message box, my youtube video does not display - instead i just see gobblygook code. I am posting under the name 'Pillars', three posts up from the bottom at: http://www.love2escape.com/chat/discussion/109/new-zealand/
  • I've had success with embedding something like the following: <object type="application/x-shockwave-flash" data="http://www.yourdomain.com/wordpress/wp-content/plugins/dewmp3-1.4-EN/dewplayer.swf?son=http://www.yourdomain.com/wordpress/wp-content/plugins/dewmp3-1.4-EN/the_thrill.mp3" width="200" height="20"><param name="movie" value="http://www.yourdomain.com/wordpress/wp-content/plugins/dewmp3-1.4-EN/dewplayer.swf?son=http://www.yourdomain.com/wordpress/wp-content/plugins/dewmp3-1.4-EN/the_thrill.mp3" /> </object> It looks similar. Where did you get the code script you used?
  • Jim, I followed the tip above, and downloaded earlier today, Better BBCode extension at http://lussumo.com/addons/?PostBackAction=AddOn&AddOnID=31 I then tweaked the code, as mentioned by Dinoboff above (at the url he mentions) I'm probably doing something stupid.
  • ithcyithcy New
    edited October 2006
    $String = preg_replace('/\<youtube\>(.+?)\<\/youtube\>/', '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>', $String);
    this won't work. the second argument to preg_replace() needs to be in double quotes, otherwise variable interpolation is turned off and $1 won't be replaced with the youtube ID.

    in other words:
    $String = preg_replace('/\<youtube\>(.+?)\<\/youtube\>/', "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/$1\"></param><embed src=\"http://www.youtube.com/v/$1\" type=\"application/x-shockwave-flash\" width=\"425\" height=\"350\"></embed></object>", $String);
    this may not be the only problem though.
  • NickENickE New
    edited October 2006
    the second argument to preg_replace() needs to be in double quotes

    No it dosn't.

    @Bergamot: I would recommend against using a wildcard to test for the youtube ID, as people could exploit it and insert malicious js into the page. Maybe something like this... (I don't think you needed to escape '<' and '>')preg_replace('/<youtube>([\d\w-_]+)<\/youtube>/i', .....);although I'm not exactly sure what characters can be in a youtube video ID
  • itchy, thanks for trying still no workie :( http://www.love2escape.com/chat/discussion/109/new-zealand/
  • SirNot, should i use preg_replace('/<youtube>([\d\w-_]+)<\/youtube>/i', .....); on that line instead?
  • NickENickE New
    edited October 2006
    it appears that it's converting the youtube video id before it changes instances of '<', '>' and '&' to their html equivelents. where are you inserting the call to preg_replace?

    EDIT: nevermind, just read the link
  • forgive my coding ignorance here, but what should i change/add?
  • oops sorry, just after seeing your second sentence above. in the default.php of that extension i have $parser = new HTML_BBCodeParser(); if ($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) { $String = $this->ProtectString($String); $String = $parser->qparse($String); $String = preg_replace('/\<youtube\>(.+?)\<\/youtube\>/', "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/$1\"></param><embed src=\"http://www.youtube.com/v/$1\" type=\"application/x-shockwave-flash\" width=\"425\" height=\"350\"></embed></object>", $String); return $String; } else return $String; NOTE - the above contains Itchy's suggested replace line....will need to change that back maybe - after what you said above.
  • NickENickE New
    edited October 2006
    well if you apply the mod correctly, then it should work. However, I would suggest modifying the function in default.php like so:
       function Parse($String, $Object, $FormatPurpose)
       {
          $parser = new HTML_BBCodeParser();
    
          if ($FormatPurpose == FORMAT_STRING_FOR_DISPLAY)
          {
             $String = $this->ProtectString($String);
             $String = $parser->qparse($String);
             return preg_replace('/<youtube>([\d\w-_]+)<\/youtube>/i', 
    			'<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param>
    			<embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed>
    			</object>', $String);
          }
          else
             return $String;
       }
    rather than what Bergamot originally posted, as youtube video ids can have underscores and hyphens in them.
  • reverting back to the original, the code i have is: $parser = new HTML_BBCodeParser(); if ($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) { $String = $this->ProtectString($String); $String = $parser->qparse($String); $String = preg_replace('/\<youtube\>(.+?)\<\/youtube\>/', '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>', $String); return $String; } else return $String; }
  • thanks SirNot, i will try your suggestion now on my site
  • nope, still not working :(
  • NickENickE New
    edited October 2006
    And you are using the Better BB-Code 1.0 extension? No other modifications? What other formatters have you installed? This may sound stupid, but you have selected bbcode as your formatting option, and used the bbcode tags [youtube]vid id[/youtube] to post it, right?

    It's really strange, because I just downloaded/modified the extension and it's working fine for me.
  • yes, I am using Better BB-Code 1.0 (downloaded it this morning) I haven't modified it apart from what was recommended above in Dinoboff's post/link http://lussumo.com/community/discussion/3942/embed-youtube/#Item_3 and then I editted again a few mins ago, using your code above. yes, I always click the bbcode button for my formatting option, when i try to post the youtube video. :) as for the bbcode tags, i am unsure what you mean. I just post the embed code that i copy/paste from the youtube site eg <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/PcWrB9B485s"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/PcWrB9B485s" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>
  • as for what other formatters have installed I am not clear here what they might be lesseee looking at my extensions here, i have: Account Pictures 1.0 Atom Feed 1.0 Attachments 2.0 Better BB Code 1.0 Discussion Filters 1.0 Extended Text Formatter 1.0 Html Formatter 1.6 Inline Images 1.0 Page Management 2.3 Quotations 1.5 Vanillacons 1.1
This discussion has been closed.