Class: C80Features::ImageContainerBgUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- C80Features::ImageContainerBgUploader
- Includes:
- CarrierWave::MiniMagick
- Defined in:
- app/uploaders/c80_features/image_container_bg_uploader.rb
Overview
грузит картинку слайдера
Instance Method Summary collapse
- #filename ⇒ Object
-
#resize_to_big_by_width ⇒ Object
меням размер оригинальной картинки, подгоняя её к требуемой ширине (высота рассчитается автоматом).
- #resize_to_limit_my ⇒ Object
-
#resize_to_preview ⇒ Object
пока используется только для показа картинки в админке.
- #store_dir ⇒ Object
Instance Method Details
#filename ⇒ Object
25 26 27 28 29 |
# File 'app/uploaders/c80_features/image_container_bg_uploader.rb', line 25 def filename if original_filename "image_#{secure_token(4)}.#{file.extension}" end end |
#resize_to_big_by_width ⇒ Object
меням размер оригинальной картинки, подгоняя её к требуемой ширине (высота рассчитается автоматом)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/uploaders/c80_features/image_container_bg_uploader.rb', line 48 def resize_to_big_by_width manipulate! do |img| # извлекаем ширину и подгоняем высоту w = C80Features::Prop.first.bg_big_width h = calc_height_of_image(w) # меняем размер img.resize "#{w}x#{h}<" img = yield(img) if block_given? img end end |
#resize_to_limit_my ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/uploaders/c80_features/image_container_bg_uploader.rb', line 31 def resize_to_limit_my manipulate! do |img| # извлекаем ширину и подгоняем высоту w = C80Features::Prop.first.bg_image_limit_width h = C80Features::Prop.first.bg_image_limit_height # меняем размер img.resize "#{w}x#{h}<" img = yield(img) if block_given? img end end |
#resize_to_preview ⇒ Object
пока используется только для показа картинки в админке
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/uploaders/c80_features/image_container_bg_uploader.rb', line 66 def resize_to_preview manipulate! do |img| w = C80Features::Prop.first.bg_preview_width h = C80Features::Prop.first.bg_preview_height img.resize "#{w}x#{h}>" img = yield(img) if block_given? img end end |
#store_dir ⇒ Object
21 22 23 |
# File 'app/uploaders/c80_features/image_container_bg_uploader.rb', line 21 def store_dir 'uploads/features/bg' end |