Module: RnStack::ImageHelper
- Defined in:
- app/helpers/rn_stack/image_helper.rb
Instance Method Summary collapse
-
#pro_image_tag(attachment, options = {}) ⇒ Object
A professional wrapper for active_storage.
Instance Method Details
#pro_image_tag(attachment, options = {}) ⇒ Object
A professional wrapper for active_storage
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/rn_stack/image_helper.rb', line 4 def pro_image_tag(, = {}) return unless .attached? # Default transformations transformations = { resize_to_limit: [:size] || [800, 800], format: :webp, saver: { quality: 80 } } # Advanced transformations transformations[:crop] = "#{[:crop_w]}x#{[:crop_h]}+#{[:x]}+#{[:y]}" if [:crop] transformations[:monochrome] = true if [:grayscale] image_tag .variant(transformations) end |