forked from ePages-de/epages-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.rb
20 lines (17 loc) · 781 Bytes
/
image.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Jekyll
class ImageBlock < Liquid::Tag
def initialize(tag_name, data, tokens)
super
params = data.split(" ")
raise 'ImageBlock must be used with "filename [width] [float]"' if params.size > 3
@url, @width, @float = params
end
def render(context)
url = unless @url =~ /^https?:\/\// then context.registers[:site].baseurl + '/assets/images/apps/' + @url else @url end
width_html = unless @width.nil? then "style='width: #{@width}'" else '' end
image_html = "<img src='#{url}' alt='#{@url}' #{width_html if @float.nil?}/>"
"<a class='imagebox #{@float}' #{width_html if @float} href='#{url}' data-lightbox='imagebox'>#{image_html}</a>"
end
end
end
Liquid::Template.register_tag('image', Jekyll::ImageBlock)