Skip to content

Instantly share code, notes, and snippets.

@peranakanfrancis
Last active November 26, 2018 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peranakanfrancis/e51ae72c2c697c0c4971f2b837935f03 to your computer and use it in GitHub Desktop.
Save peranakanfrancis/e51ae72c2c697c0c4971f2b837935f03 to your computer and use it in GitHub Desktop.
A plugin for embedding videos from Vimeo using a simple Liquid tag, ie: {% vimeo 12345678 %}.
module Jekyll
  class Vimeo < Liquid::Tag
    @@width = 500
    @@height = 281

    def initialize(name, id, tokens)
      super
      @id = id
    end

    def render(context)
      %(<iframe width="#{@@width}" height="#{@@height}" 
      src="http://player.vimeo.com/video/#{@id}" 
      frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>)
    end
  end
end

Liquid::Template.register_tag('vimeo', Jekyll::Vimeo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment