lib/cloudinary/carrier_wave/process.rb in cloudinary-1.0.80 vs lib/cloudinary/carrier_wave/process.rb in cloudinary-1.0.81

- old
+ new

@@ -133,25 +133,29 @@ @tags ||= self.all_processors.select{|processor| processor[0] == :tags}.map(&:second).first raise CloudinaryException, "tags cannot be used in versions." if @tags.present? && self.version_name.present? @tags end - def format + def requested_format format_processor = self.all_processors.find{|processor| processor[0] == :convert} if format_processor # Explicit format is given format = Array(format_processor[1]).first elsif self.transformation.include?(:format) format = self.transformation[:format] elsif self.version_name.present? # No local format. The reset should be handled by main uploader uploader = self.model.send(self.mounted_as) format = uploader.format - else - # Try to auto-detect format - format = Cloudinary::PreloadedFile.split_format(original_filename || "").last - format ||= "png" # TODO Default format? end + format + end + + def format + format = Cloudinary::PreloadedFile.split_format(original_filename || "").last + return format || "" if resource_type == "raw" + format = requested_format || format || default_format + format = format.to_s.downcase Cloudinary::FORMAT_ALIASES[format] || format end end