mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
parent
3f82882301
commit
3d6011d7b9
3 changed files with 0 additions and 45 deletions
|
@ -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"'
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
Loading…
Reference in a new issue