Sha256: 1785698154b8bd4d1ef63059eeed87cd91a7ddd29b62ed0a13a3a8726da86c6e
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
module Middleman::Extensions module AutomaticImageSizes class << self def registered(app) require "middleman/extensions/automatic_image_sizes/fastimage" app.send :include, InstanceMethods end alias :included :registered end module InstanceMethods def image_tag(path, params={}) if !params.has_key?(:width) && !params.has_key?(:height) && !path.include?("://") params[:alt] ||= "" http_prefix = http_images_path rescue images_dir begin real_path = File.join(source, images_dir, path) full_path = File.expand_path(real_path, root) http_prefix = http_images_path rescue images_dir if File.exists? full_path dimensions = ::FastImage.size(full_path, :raise_on_failure => true) params[:width] = dimensions[0] params[:height] = dimensions[1] end rescue # $stderr.puts params.inspect end end super(path, params) end end end register :automatic_image_sizes, AutomaticImageSizes end
Version data entries
4 entries across 4 versions & 1 rubygems