1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Remove automatic alt text feature (#2320)

Fixes #2319
This commit is contained in:
bravegrape 2020-05-10 02:41:49 +02:00 committed by GitHub
parent 3f82882301
commit 3d6011d7b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 45 deletions

View file

@ -1,8 +0,0 @@
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

@ -127,13 +127,6 @@ Middleman::Extensions.register :automatic_image_sizes do
Middleman::Extensions::AutomaticImageSizes Middleman::Extensions::AutomaticImageSizes
end end
# AutomaticAltTags uses the file name of the `image_tag` to generate
# a default `:alt` value.
Middleman::Extensions.register :automatic_alt_tags do
require 'middleman-core/extensions/automatic_alt_tags'
Middleman::Extensions::AutomaticAltTags
end
Middleman::Extensions.register :external_pipeline do Middleman::Extensions.register :external_pipeline do
require 'middleman-core/extensions/external_pipeline' require 'middleman-core/extensions/external_pipeline'
Middleman::Extensions::ExternalPipeline Middleman::Extensions::ExternalPipeline

View file

@ -1,30 +0,0 @@
# Automatic Image alt tags from image names extension
class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
helpers do
# Override default image_tag helper to automatically insert alt tag
# containing image name.
def image_tag(path, options_hash = ::Middleman::EMPTY_HASH)
options = options_hash.dup
unless path.include?('://')
options[:alt] ||= ''
real_path = path.dup
real_path = File.join(config[:images_dir], real_path) unless real_path.start_with?('/')
file = app.files.find(:source, real_path)
if file && file[:full_path].exist?
begin
alt_text = File.basename(file[:full_path].to_s, '.*')
alt_text.capitalize!
options[:alt] = alt_text
end
end
end
super(path, options)
end
end
end