Merge pull request #1522 from paulozoom/patch-1

Add retina files support on automatic_image_sizes
This commit is contained in:
Thomas Reynolds 2015-05-09 14:13:34 -07:00
commit 72916dec13

View file

@ -23,6 +23,13 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
if File.exist?(full_path) if File.exist?(full_path)
begin begin
width, height = ::FastImage.size(full_path, raise_on_failure: true) width, height = ::FastImage.size(full_path, raise_on_failure: true)
# Check for @2x and @3x image
retina = full_path.match(/@(\d)x\.[a-zA-Z]{3,4}$/)
if retina
factor = retina[1].to_i
width = width / factor
height = height / factor
end
params[:width] = width params[:width] = width
params[:height] = height params[:height] = height
rescue FastImage::UnknownImageType rescue FastImage::UnknownImageType