> ## Content Index
> Fetch the complete content index at: https://www.frank.be/llms.txt
> Use this file to discover other available public pages before exploring further.

# YouTube video filter voor Mephisto
- URL: https://www.frank.be/20070730youtube-video-filter-voor-mephisto/
- Published: 2007-07-29T22:00:00.000Z
- Updated: 2026-06-21T17:38:00.000Z
- Author: Frank Louwers

We willen allemaal nu en dan eens een video-tje van YouTube of Google Video in onze postings opnemen. Wat de meesten onder ons doen is de "Embed me" functie van die sites gebruiken, en het volledig stuk HTML code overnemen. Wie [Mephisto](http://mephistoblog.com/?ref=frank.be) gebruikt, kan gebruik maken van onderstaande macro om het allemaal een stuk eenvoudiger te maken. Je hoeft dan enkel maar <filter:video vid="XXX" type="youtube"> op te nemen in je posting, en Mephisto vult automatisch de juiste flash embed html code in.

Maak de directory `vendor/plugins/filtered_column_video_macro` aan, maak een bestand init.rb met volgende inhoud:

    1 class VideoMacro < FilteredColumn::Macros::Base
    2 
    3   def self.filter(attrib, inner_text = '', text = '')
    4     vid     = attrib[:vid]
    5     width   = attrib[:width].blank? ? 425 : attrib[:width]
    6     height  = attrib[:height].blank? ? 350 : attrib[:height]
    7     type    = attrib[:type]
    8     style   = attrib[:style]
    9 
   10     p attrib ;
   11 
   12     if vid =~ /^[A-Z][A-Za-z0-9]+$/ or type == "youtube"
   13       "<div style=\"#{style}\"><object width=\"#{width}\"
   14        height=\"#{height}\"><param name=\"movie\"
   15        value=\"http://www.youtube.com/v/#{vid}\"></param><param
   16        name=\"wmode\" value=\"transparent\"></param><embed
   17        src=\"http://www.youtube.com/v/#{vid}\"
   18        type=\"application/x-shockwave-flash\" wmode=\"transparent\"
   19        width=\"#{width}\" height=\"#{height}\"></embed></object></div>"
   20     elsif vid =~ /^[0-9]+$/ or type == "google"
   21       "<div style=\"#{style}\"><embed style=\"width:#{width}px;
   22       height:#{height}px;\" id=\"VideoPlayback\"
   23       type=\"application/x-shockwave-flash\" src=
   24       \"http://video.google.com/googleplayer.swf?docId=#{vid}&hl=en\">
   25       </embed></div>"
   26     else
   27       "Invalid Video or unsupported site!"
   28     end
   29 
   30   end
   31 end