diff options
-rw-r--r-- | _plugins/image.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/_plugins/image.rb b/_plugins/image.rb new file mode 100644 index 0000000..93b70e9 --- /dev/null +++ b/_plugins/image.rb @@ -0,0 +1,23 @@ +module Jekyll + class ImageTag < Liquid::Tag + + def initialize(tag_name, parameters, tokens) + super + @params = {} + parameters.scan(/(\w+)\s*=\s*"([^"]+)"/) do |key, value| + @params[key] = value + end + end + + def render(context) + url = @params['url'] + alt = @params['alt'] + if alt + "<img src='#{url}' alt='#{alt}' />" + else + "<img src='#{url}' />" + end + end + Liquid::Template.register_tag('image', self) + end +end |