1. Added image tag plugin
2. Removed figure tag plugin 3. Renamed custom_filters to octopress_filters 4. Added styles to support new image tag plugin
This commit is contained in:
parent
8e489ac2da
commit
a2bc6f9762
4 changed files with 65 additions and 75 deletions
41
plugins/image_tag.rb
Normal file
41
plugins/image_tag.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Title: Simple Image tag for Jekyll
|
||||
# Author: Brandon Mathis http://brandonmathis.com
|
||||
# Description: Easily output images with optional class names and title/alt attributes
|
||||
#
|
||||
# Syntax {% image [class name(s)] url [title text] %}
|
||||
#
|
||||
# Example:
|
||||
# {% imaeg left half http://site.com/images/ninja.png Ninja Attack! %}
|
||||
#
|
||||
# Output:
|
||||
# <image class='left' src="http://site.com/images/ninja.png" title="Ninja Attack!" alt="Ninja Attack!">
|
||||
#
|
||||
|
||||
module Jekyll
|
||||
|
||||
class ImageTag < Liquid::Tag
|
||||
@img = nil
|
||||
@title = nil
|
||||
@class = ''
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
if markup =~ /(\S.*\s+)?(https?:\/\/|\/)(\S+)(\s+.+)?/i
|
||||
@class = $1
|
||||
@img = $2 + $3
|
||||
@title = $4
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def render(context)
|
||||
output = super
|
||||
if @img
|
||||
figure = "<img class='#{@class}' src='#{@img}' alt='#{@title}' title='#{@title}'>"
|
||||
else
|
||||
"Error processing input, expected syntax: {% img [class name(s)] /url/to/image [title text] %}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('img', Jekyll::ImageTag)
|
Loading…
Add table
Add a link
Reference in a new issue