diff --git a/middleman-core/features/automatic_alt_tags.feature b/middleman-core/features/automatic_alt_tags.feature new file mode 100644 index 00000000..12e84459 --- /dev/null +++ b/middleman-core/features/automatic_alt_tags.feature @@ -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"' \ No newline at end of file diff --git a/middleman-core/fixtures/automatic-alt-tags-app/config.rb b/middleman-core/fixtures/automatic-alt-tags-app/config.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman-core/fixtures/automatic-alt-tags-app/source/auto-image-sizes.html.erb b/middleman-core/fixtures/automatic-alt-tags-app/source/auto-image-sizes.html.erb new file mode 100755 index 00000000..fb441334 --- /dev/null +++ b/middleman-core/fixtures/automatic-alt-tags-app/source/auto-image-sizes.html.erb @@ -0,0 +1 @@ +<%= image_tag "blank.gif" %> \ No newline at end of file diff --git a/middleman-core/fixtures/automatic-alt-tags-app/source/images/blank.gif b/middleman-core/fixtures/automatic-alt-tags-app/source/images/blank.gif new file mode 100755 index 00000000..2498f1aa Binary files /dev/null and b/middleman-core/fixtures/automatic-alt-tags-app/source/images/blank.gif differ diff --git a/middleman-core/lib/middleman-more/extensions/automatic_alt_tags.rb b/middleman-core/lib/middleman-more/extensions/automatic_alt_tags.rb index 879cecee..ca1b4a7c 100644 --- a/middleman-core/lib/middleman-more/extensions/automatic_alt_tags.rb +++ b/middleman-core/lib/middleman-more/extensions/automatic_alt_tags.rb @@ -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