Added theme_image_tag liquid tag to make it easy to insert theme image files
This commit is contained in:
parent
083debc516
commit
9d11d9e019
@ -38,6 +38,16 @@ module Locomotive
|
|||||||
|
|
||||||
asset_url(input)
|
asset_url(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Write a theme image tag
|
||||||
|
# input: name of file including folder
|
||||||
|
# example: 'about/myphoto.jpg' | theme_image # <img src="images/about/myphoto.jpg" />
|
||||||
|
def theme_image_tag(input, *args)
|
||||||
|
return '' if input.nil?
|
||||||
|
input = "images/#{input}" unless input.starts_with?('/')
|
||||||
|
image_options = inline_options(args_to_options(args))
|
||||||
|
"<img src=\"#{asset_url(input)}\" #{image_options}/>"
|
||||||
|
end
|
||||||
|
|
||||||
# Write an image tag
|
# Write an image tag
|
||||||
# input: url of the image OR asset drop
|
# input: url of the image OR asset drop
|
||||||
|
@ -44,6 +44,14 @@ describe Locomotive::Liquid::Filters::Html do
|
|||||||
javascript_tag('/trash/main.js').should == result
|
javascript_tag('/trash/main.js').should == result
|
||||||
javascript_tag('/trash/main').should == result
|
javascript_tag('/trash/main').should == result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should return an image tag for a given theme file without parameters' do
|
||||||
|
theme_image_tag('foo.jpg').should == "<img src=\"/sites/000000000000000000000042/theme/images/foo.jpg\" />"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return an image tag for a given theme file with size' do
|
||||||
|
theme_image_tag('foo.jpg', 'width:100', 'height:100').should == "<img src=\"/sites/000000000000000000000042/theme/images/foo.jpg\" height=\"100\" width=\"100\" />"
|
||||||
|
end
|
||||||
|
|
||||||
it 'should return an image tag without parameters' do
|
it 'should return an image tag without parameters' do
|
||||||
image_tag('foo.jpg').should == "<img src=\"foo.jpg\" />"
|
image_tag('foo.jpg').should == "<img src=\"foo.jpg\" />"
|
||||||
|
Loading…
Reference in New Issue
Block a user