lib/paperclip/interpolations.rb in paperclip-4.1.1 vs lib/paperclip/interpolations.rb in paperclip-4.2.0

- old
+ new

@@ -99,9 +99,17 @@ def extension attachment, style_name ((style = attachment.styles[style_name.to_s.to_sym]) && style[:format]) || File.extname(attachment.original_filename).gsub(/\A\.+/, "") end + # Returns the dot+extension of the file. e.g. ".jpg" for "file.jpg" + # If the style has a format defined, it will return the format instead + # of the actual extension. If the extension is empty, no dot is added. + def dotextension attachment, style_name + ext = extension(attachment, style_name) + ext.empty? ? "" : ".#{ext}" + end + # Returns an extension based on the content type. e.g. "jpeg" for # "image/jpeg". If the style has a specified format, it will override the # content-type detection. # # Each mime type generally has multiple extensions associated with it, so