| ... | ... |
@@ -17,12 +17,20 @@ module Jekyll |
| 17 | 17 |
@img = nil |
| 18 | 18 |
@title = nil |
| 19 | 19 |
@class = '' |
| 20 |
+ @width = '' |
|
| 21 |
+ @height = '' |
|
| 20 | 22 |
|
| 21 | 23 |
def initialize(tag_name, markup, tokens) |
| 22 |
- if markup =~ /(\S.*\s+)?(https?:\/\/|\/)(\S+)(\s+.+)?/i |
|
| 23 |
- @class = $1 |
|
| 24 |
+ if markup =~ /(\S.*\s+)?(https?:\/\/|\/)(\S+)(\s+\d+\s+\d+)?(\s+.+)?/i |
|
| 25 |
+ @class = $1 || '' |
|
| 24 | 26 |
@img = $2 + $3 |
| 25 |
- @title = $4 |
|
| 27 |
+ if $5 |
|
| 28 |
+ @title = $5.strip |
|
| 29 |
+ end |
|
| 30 |
+ if $4 =~ /\s*(\d+)\s+(\d+)/ |
|
| 31 |
+ @width = $1 |
|
| 32 |
+ @height = $2 |
|
| 33 |
+ end |
|
| 26 | 34 |
end |
| 27 | 35 |
super |
| 28 | 36 |
end |
| ... | ... |
@@ -30,9 +38,9 @@ module Jekyll |
| 30 | 30 |
def render(context) |
| 31 | 31 |
output = super |
| 32 | 32 |
if @img |
| 33 |
- "<img class='#{@class}' src='#{@img}' alt='#{@title}' title='#{@title}'>"
|
|
| 33 |
+ "<img class='#{@class}' src='#{@img}' width='#{@width}' height='#{@height}' alt='#{@title}' title='#{@title}'>"
|
|
| 34 | 34 |
else |
| 35 |
- "Error processing input, expected syntax: {% img [class name(s)] /url/to/image [title text] %}"
|
|
| 35 |
+ "Error processing input, expected syntax: {% img [class name(s)] /url/to/image [width height] [title text] %}"
|
|
| 36 | 36 |
end |
| 37 | 37 |
end |
| 38 | 38 |
end |