1
0
Fork 0
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:
Thomas Reynolds 2014-08-03 08:29:29 -07:00
parent b39b913cfb
commit 724eab3ac9
5 changed files with 11 additions and 6 deletions

View 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"'

View file

@ -0,0 +1 @@
<%= image_tag "blank.gif" %>

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

View file

@ -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