mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
fix alt tags and add test. Closes #1341
This commit is contained in:
parent
b39b913cfb
commit
724eab3ac9
5 changed files with 11 additions and 6 deletions
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
middleman-core/fixtures/automatic-alt-tags-app/config.rb
Normal file
0
middleman-core/fixtures/automatic-alt-tags-app/config.rb
Normal file
|
@ -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
|
||||
class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
|
||||
def initialize(app, options_hash={}, &block)
|
||||
super
|
||||
end
|
||||
|
||||
helpers do
|
||||
# Override default image_tag helper to automatically insert alt tag
|
||||
# containing image name.
|
||||
|
||||
def image_tag(path)
|
||||
def image_tag(path, params={})
|
||||
unless path.include?('://')
|
||||
params[:alt] ||= ''
|
||||
|
||||
|
@ -25,7 +21,7 @@ class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
|
|||
end
|
||||
end
|
||||
|
||||
super(path)
|
||||
super(path, params)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue