Skip to content

Instantly share code, notes, and snippets.

@kurnias
Created February 6, 2015 10:12
Show Gist options
  • Save kurnias/c4fc4f1fa2231a28f860 to your computer and use it in GitHub Desktop.
Save kurnias/c4fc4f1fa2231a28f860 to your computer and use it in GitHub Desktop.
lightbox.rb
# 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="/images/#{path}" rel="lightbox" title="#{title}"><img src="/images/#{path}" height="384" width="512" 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