aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-07-29 18:29:39 -0400
committerBrandon Mathis <brandon@imathis.com>2011-07-29 18:29:53 -0400
commitc837acd497dd1b58ab6c12cf726fda228ac1418e (patch)
treef0c48b02974a22880651ab1967081bd1ff740e3a /plugins
parentd6744967fa7572101202d239727b7983004e9603 (diff)
downloadmy_new_personal_website-c837acd497dd1b58ab6c12cf726fda228ac1418e.tar.xz
my_new_personal_website-c837acd497dd1b58ab6c12cf726fda228ac1418e.zip
added support for width and height to image tag plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/image_tag.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/plugins/image_tag.rb b/plugins/image_tag.rb
index 7be4003d..25a38df5 100644
--- a/plugins/image_tag.rb
+++ b/plugins/image_tag.rb
@@ -17,12 +17,20 @@ module Jekyll
@img = nil
@title = nil
@class = ''
+ @width = ''
+ @height = ''
def initialize(tag_name, markup, tokens)
- if markup =~ /(\S.*\s+)?(https?:\/\/|\/)(\S+)(\s+.+)?/i
- @class = $1
+ if markup =~ /(\S.*\s+)?(https?:\/\/|\/)(\S+)(\s+\d+\s+\d+)?(\s+.+)?/i
+ @class = $1 || ''
@img = $2 + $3
- @title = $4
+ if $5
+ @title = $5.strip
+ end
+ if $4 =~ /\s*(\d+)\s+(\d+)/
+ @width = $1
+ @height = $2
+ end
end
super
end
@@ -30,9 +38,9 @@ module Jekyll
def render(context)
output = super
if @img
- "<img class='#{@class}' src='#{@img}' alt='#{@title}' title='#{@title}'>"
+ "<img class='#{@class}' src='#{@img}' width='#{@width}' height='#{@height}' alt='#{@title}' title='#{@title}'>"
else
- "Error processing input, expected syntax: {% img [class name(s)] /url/to/image [title text] %}"
+ "Error processing input, expected syntax: {% img [class name(s)] /url/to/image [width height] [title text] %}"
end
end
end