fix alt tags and add test. Closes #1341
This commit is contained in:
parent
b39b913cfb
commit
724eab3ac9
8
middleman-core/features/automatic_alt_tags.feature
Normal file
8
middleman-core/features/automatic_alt_tags.feature
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Feature: Automatically detect and insert image dimensions into tags
|
||||||
|
In order to speed up development and appease YSlow
|
||||||
|
|
||||||
|
Scenario: Rendering an image with the feature enabled
|
||||||
|
Given "automatic_alt_tags" feature is "enabled"
|
||||||
|
And the Server is running at "automatic-alt-tags-app"
|
||||||
|
When I go to "/auto-image-sizes.html"
|
||||||
|
Then I should see 'alt="Blank"'
|
|
@ -0,0 +1 @@
|
||||||
|
<%= image_tag "blank.gif" %>
|
BIN
middleman-core/fixtures/automatic-alt-tags-app/source/images/blank.gif
Executable file
BIN
middleman-core/fixtures/automatic-alt-tags-app/source/images/blank.gif
Executable file
Binary file not shown.
After Width: | Height: | Size: 43 B |
|
@ -1,14 +1,10 @@
|
||||||
# Automatic Image alt tags from image names extension
|
# Automatic Image alt tags from image names extension
|
||||||
class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
|
class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
|
||||||
def initialize(app, options_hash={}, &block)
|
|
||||||
super
|
|
||||||
end
|
|
||||||
|
|
||||||
helpers do
|
helpers do
|
||||||
# Override default image_tag helper to automatically insert alt tag
|
# Override default image_tag helper to automatically insert alt tag
|
||||||
# containing image name.
|
# containing image name.
|
||||||
|
|
||||||
def image_tag(path)
|
def image_tag(path, params={})
|
||||||
unless path.include?('://')
|
unless path.include?('://')
|
||||||
params[:alt] ||= ''
|
params[:alt] ||= ''
|
||||||
|
|
||||||
|
@ -25,7 +21,7 @@ class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
super(path)
|
super(path, params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue