Module: Ckeditor::Backend::CarrierWave::InstanceMethods
- Defined in:
- lib/ckeditor/backend/carrierwave.rb
Instance Method Summary collapse
- #extract_content_type ⇒ Object
-
#quality(percentage) ⇒ Object
process :quality => 85.
- #read_dimensions ⇒ Object
- #set_size ⇒ Object
-
#strip ⇒ Object
process :strip.
Instance Method Details
#extract_content_type ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/ckeditor/backend/carrierwave.rb', line 40 def extract_content_type if file.content_type == 'application/octet-stream' || file.content_type.blank? content_type = MIME::Types.type_for(original_filename).first else content_type = file.content_type end model.data_content_type = content_type.to_s end |
#quality(percentage) ⇒ Object
process :quality => 85
32 33 34 35 36 37 38 |
# File 'lib/ckeditor/backend/carrierwave.rb', line 32 def quality(percentage) manipulate! do |img| img.quality(percentage) img = yield(img) if block_given? img end end |
#read_dimensions ⇒ Object
54 55 56 57 58 59 |
# File 'lib/ckeditor/backend/carrierwave.rb', line 54 def read_dimensions if model.image? && model.has_dimensions? magick = ::MiniMagick::Image.new(current_path) model.width, model.height = magick[:width], magick[:height] end end |
#set_size ⇒ Object
50 51 52 |
# File 'lib/ckeditor/backend/carrierwave.rb', line 50 def set_size model.data_file_size = file.size end |
#strip ⇒ Object
process :strip
23 24 25 26 27 28 29 |
# File 'lib/ckeditor/backend/carrierwave.rb', line 23 def strip manipulate! do |img| img.strip img = yield(img) if block_given? img end end |