From 22db588dda817e0181b733332272191e61d85e5d Mon Sep 17 00:00:00 2001 From: uvok cheetah Date: Sun, 6 Oct 2024 11:02:31 +0200 Subject: Add image tag --- _plugins/image.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 _plugins/image.rb 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 + "#{alt}" + else + "" + end + end + Liquid::Template.register_tag('image', self) + end +end -- cgit v1.2.3