lib/ext.rb in no-style-please2-plugins-0.4.2 vs lib/ext.rb in no-style-please2-plugins-0.4.3
- old
+ new
@@ -25,11 +25,16 @@
class AssetImg < Liquid::Tag
def initialize(tag_name, text, tokens)
- @img_name = text.strip
+ arr = text.strip.split(" ")
+ @img_name = arr[0]
+ @img_width = nil
+ if arr.count > 1
+ @img_width = arr[1]
+ end
end
def render(context)
path = context['page']['path']
@@ -41,10 +46,17 @@
base = $g_config['baseurl']
link = "/pics/#{dirPath}/#{@img_name}"
if base && base.length
link = "#{base}/pics/#{dirPath}/#{@img_name}"
end
- return "![](#{link})"
+
+ if @img_width != nil
+ return "<img src='#{link}' style='width:#{@img_width}px'>"
+ else
+ return "![](#{link})"
+ end
+
+
end
end
class ImgLink < Liquid::Tag
\ No newline at end of file