Skip to content

Instantly share code, notes, and snippets.

@melborne
Created November 8, 2012 00:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save melborne/4035604 to your computer and use it in GitHub Desktop.
Save melborne/4035604 to your computer and use it in GitHub Desktop.
Jekyll Lightbox Image Plugin
# A Liquid tag for Jekyll sites that allows embedding Lightbox images.
# by: kyoendo
# Source URL: https://gist.github.com/4035604
#
# Example usage: {% lightbox 2012/abc.png, Title of Image, Alt Title %}
module Jekyll
class LightboxTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
end
def render(context)
path, title, alt = @text.split(',').map(&:strip)
%{<a href="/assets/images/#{path}" rel="lightbox" title="#{title}"><img src="/assets/images/#{path}" alt="#{alt || title}" /></a>}
end
end
end
Liquid::Template.register_tag('lightbox', Jekyll::LightboxTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment