From 724eab3ac942f01638015afd916f26770e0bfade Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 3 Aug 2014 08:29:29 -0700 Subject: [PATCH] fix alt tags and add test. Closes #1341 --- middleman-core/features/automatic_alt_tags.feature | 8 ++++++++ .../fixtures/automatic-alt-tags-app/config.rb | 0 .../source/auto-image-sizes.html.erb | 1 + .../automatic-alt-tags-app/source/images/blank.gif | Bin 0 -> 43 bytes .../extensions/automatic_alt_tags.rb | 8 ++------ 5 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 middleman-core/features/automatic_alt_tags.feature create mode 100644 middleman-core/fixtures/automatic-alt-tags-app/config.rb create mode 100755 middleman-core/fixtures/automatic-alt-tags-app/source/auto-image-sizes.html.erb create mode 100755 middleman-core/fixtures/automatic-alt-tags-app/source/images/blank.gif 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 0000000000000000000000000000000000000000..2498f1aac58dab923f0fd99b1c8ee6b8c53c7158 GIT binary patch literal 43 scmZ?wbhEHbWMp7uXkcKtd-pB_1B2pE79h#MpaUX6G7L;iE{qJ;0KEqWk^lez literal 0 HcmV?d00001 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