Modifications for images in html code

This commit is contained in:
chris2tof committed 2011-10-18 11:21:24 +08:00
1 parent 0ca354cfd0
commit 2e86d8081f
10 files changed
+110 -118

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ class AssetUploader < CarrierWave::Uploader::Base
process :set_content_type
def set_content_type(*args)
content_type = file.content_type == 'binary/octet-stream' || 'application/octet-stream' || file.content_type.blank? ? MIME::Types.type_for(original_filename).first.to_s : file.content_type
content_type = file.content_type == ('binary/octet-stream' || 'application/octet-stream') || file.content_type.blank? ? MIME::Types.type_for(original_filename).first.to_s : file.content_type
self.file.instance_variable_set(:@content_type, content_type)
end
+11 -11
View File
@@ -12,7 +12,7 @@ class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def set_content_type(*args)
content_type = file.content_type == 'binary/octet-stream' || 'application/octet-stream' || file.content_type.blank? ? MIME::Types.type_for(original_filename).first.to_s : file.content_type
content_type = file.content_type == ('binary/octet-stream' || 'application/octet-stream') || file.content_type.blank? ? MIME::Types.type_for(original_filename).first.to_s : file.content_type
self.file.instance_variable_set(:@content_type, content_type)
end
@@ -58,14 +58,14 @@ class ImageUploader < CarrierWave::Uploader::Base
# "something.jpg" if original_filename
# end
# def manipulate!
# raise current_path.inspect
# image = ::MiniMagick::Image.open(current_path)
# image = yield(image)
# image.write(current_path)
# ::MiniMagick::Image.open(current_path)
# rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
# raise CarrierWave::ProcessingError.new("Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: #{e}")
# end
def manipulate!
cache_stored_file! if !cached?
image = ::MiniMagick::Image.open(current_path)
image = yield(image)
image.write(current_path)
::MiniMagick::Image.open(current_path)
rescue
nil
end
end