summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruvok cheetah2024-10-06 11:02:31 +0200
committeruvok cheetah2024-10-06 11:02:31 +0200
commit22db588dda817e0181b733332272191e61d85e5d (patch)
tree824b37c239b4a89643cdb442f08a7afe53624438
parent7a553b538b44e86d3ef444eaf1c0f5c9068a75bd (diff)
Add image tag
-rw-r--r--_plugins/image.rb23
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