lib/middleman-simple-thumbnailer/extension.rb in middleman-simple-thumbnailer-1.2.0 vs lib/middleman-simple-thumbnailer/extension.rb in middleman-simple-thumbnailer-1.2.1
- old
+ new
@@ -32,31 +32,34 @@
@images_store.delete
end
helpers do
- def image_tag(path, options={})
- if (resize_to = options.delete(:resize_to))
- super(image_path(path, resize_to: resize_to), options)
- else
- super(path, options)
- end
- end
+ def resized_image_path(path, resize_to=nil)
+ return path unless resize_to
- def image_path(path, options={})
- resize_to = options.delete(:resize_to)
- return super(path) unless resize_to
-
image = MiddlemanSimpleThumbnailer::Image.new(path, resize_to, app)
if app.development?
- super("data:#{image.mime_type};base64,#{image.base64_data}")
+ "data:#{image.mime_type};base64,#{image.base64_data}"
else
ext = app.extensions[:middleman_simple_thumbnailer]
ext.store_resized_image(path, resize_to)
- super(image.resized_img_path)
+ image.resized_img_path
end
end
+ def image_tag(path, options={})
+ resize_to = options.delete(:resize_to)
+ new_path = resize_to ? resized_image_path(path, resize_to) : path
+ super(new_path, options)
+ end
+
+ def image_path(path, options={})
+ resize_to = options.delete(:resize_to)
+ new_path = resize_to ? resized_image_path(path, resize_to) : path
+ super(new_path)
+ end
+
end
end
end