From 647ec149ca935a56a00653ad5111494fac50fd80 Mon Sep 17 00:00:00 2001 From: Paulo Date: Fri, 8 May 2015 23:18:11 +0200 Subject: [PATCH] Add retina files support on automatic_image_sizes --- .../lib/middleman-more/extensions/automatic_image_sizes.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb b/middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb index 56cb6ebf..f95a0d70 100644 --- a/middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb +++ b/middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb @@ -23,6 +23,13 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension if File.exist?(full_path) begin 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[:height] = height rescue FastImage::UnknownImageType