Permalink
Browse files

whoops, bad rename

  • Loading branch information...
tdreyno committed Nov 14, 2013
1 parent 4da2b02 commit 95c0fe60accc2bc5a8e4d559e0263da977ddbcb2
Showing with 32 additions and 0 deletions.
  1. +32 −0 middleman-core/lib/middleman-more/extensions/automatic_alt_tags.rb
@@ -0,0 +1,32 @@
# 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)
if !path.include?("://")
params[:alt] ||= ""
real_path = path
real_path = File.join(images_dir, real_path) unless real_path.start_with?('/')
full_path = File.join(source_dir, real_path)
if File.exists?(full_path)
begin
alt_text = File.basename(full_path, ".*")
alt_text.capitalize!
params[:alt] = alt_text
end
end
end
super(path)
end
end
end

0 comments on commit 95c0fe6

Please sign in to comment.