Sha256: 938b01aa46d9d717426820a33588fa9d50e69fc0444ba83ef77b127aaa8f0080
Contents?: true
Size: 758 Bytes
Versions: 14
Compression:
Stored size: 758 Bytes
Contents
# 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, params={}) unless 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.exist?(full_path) begin alt_text = File.basename(full_path, '.*') alt_text.capitalize! params[:alt] = alt_text end end end super(path, params) end end end
Version data entries
14 entries across 14 versions & 2 rubygems