1+ # frozen_string_literal: true
12
23module BetterTogether
34 module Attachments
5+ # Single place to manage logic for attached images
46 module Images
57 extend ActiveSupport ::Concern
68
7- VALID_IMAGE_CONTENT_TYPES = %w[ image/jpeg image/png image/gif image/webp image/svg+xml ] . freeze
9+ VALID_IMAGE_CONTENT_TYPES = %w[
10+ image/jpeg image/png image/gif image/webp image/svg+xml
11+ ] . freeze
812
913 included do
10- def self . attachable_cover_image
14+ def self . attachable_cover_image # rubocop:todo Metrics/MethodLength
1115 has_one_attached :cover_image do |attachable |
1216 attachable . variant :optimized_jpeg , resize_to_limit : [ 2400 , 1200 ] ,
1317 # rubocop:todo Layout/LineLength
1418 saver : { strip : true , quality : 85 , interlace : true , optimize_coding : true , trellis_quant : true , quant_table : 3 } , format : 'jpg'
1519 # rubocop:enable Layout/LineLength
1620 attachable . variant :optimized_png , resize_to_limit : [ 2400 , 1200 ] ,
17- saver : { strip : true , quality : 85 , optimize_coding : true } , format : 'png'
21+ saver : { strip : true , quality : 85 , optimize_coding : true } , format : 'png'
1822
1923 attachable . variant :optimized_card_jpeg , resize_to_limit : [ 1200 , 300 ] ,
20- # rubocop:todo Layout/LineLength
21- saver : { strip : true , quality : 90 , interlace : true , optimize_coding : true , trellis_quant : true , quant_table : 3 } , format : 'jpg'
24+ # rubocop:todo Layout/LineLength
25+ saver : { strip : true , quality : 90 , interlace : true , optimize_coding : true , trellis_quant : true , quant_table : 3 } , format : 'jpg'
2226 # rubocop:enable Layout/LineLength
2327 attachable . variant :optimized_card_png , resize_to_limit : [ 1200 , 300 ] ,
28+ # rubocop:todo Layout/LineLength
2429 saver : { strip : true , quality : 90 , optimize_coding : true } , format : 'png'
30+ # rubocop:enable Layout/LineLength
2531 end
2632
2733 validates :cover_image ,
2834 content_type : VALID_IMAGE_CONTENT_TYPES ,
2935 size : { less_than : 100 . megabytes , message : 'is too large' }
3036
31- alias card_image cover_image
37+ alias_method : card_image, : cover_image
3238
3339 attr_accessor :remove_cover_image
3440
@@ -73,4 +79,4 @@ def optimized_cover_image
7379 end
7480 end
7581 end
76- end
82+ end
0 commit comments