33module BetterTogether
44 # Helps with rendering images for various entities
55 module ImageHelper
6- def cover_image_tag ( entity , options = { } ) # rubocop:todo Metrics/MethodLength
6+ # rubocop:todo Metrics/PerceivedComplexity
7+ # rubocop:todo Metrics/CyclomaticComplexity
8+ # rubocop:todo Metrics/AbcSize
9+ def cover_image_tag ( entity , options = { } ) # rubocop:todo Metrics/MethodLength, Metrics/AbcSize
710 image_classes = "cover-image rounded-top #{ options [ :class ] } "
811 image_style = ( options [ :style ] ) . to_s
912 image_width = options [ :width ] || 2400
@@ -15,7 +18,7 @@ def cover_image_tag(entity, options = {}) # rubocop:todo Metrics/MethodLength
1518 class : image_classes ,
1619 style : image_style ,
1720 alt : image_alt ,
18- title : image_title ,
21+ title : image_title
1922 }
2023
2124 # Determine if entity has a profile image
@@ -33,8 +36,14 @@ def cover_image_tag(entity, options = {}) # rubocop:todo Metrics/MethodLength
3336 image_tag ( image_url ( default_image ) , **image_tag_attributes )
3437 end
3538 end
39+ # rubocop:enable Metrics/AbcSize
40+ # rubocop:enable Metrics/CyclomaticComplexity
41+ # rubocop:enable Metrics/PerceivedComplexity
3642
37- def profile_image_tag ( entity , options = { } ) # rubocop:todo Metrics/MethodLength
43+ # rubocop:todo Metrics/PerceivedComplexity
44+ # rubocop:todo Metrics/CyclomaticComplexity
45+ # rubocop:todo Metrics/AbcSize
46+ def profile_image_tag ( entity , options = { } ) # rubocop:todo Metrics/MethodLength, Metrics/AbcSize
3847 image_classes = "profile-image rounded-circle #{ options [ :class ] } "
3948 image_style = ( options [ :style ] ) . to_s
4049 image_size = options [ :size ] || 300
@@ -59,10 +68,13 @@ def profile_image_tag(entity, options = {}) # rubocop:todo Metrics/MethodLength
5968 image_tag ( attachment . url , **image_tag_attributes )
6069 else
6170 # Use a default image based on the entity type
62- default_image = default_profile_image ( entity )
71+ default_image = default_profile_image ( entity , image_format )
6372 image_tag ( image_url ( default_image ) , **image_tag_attributes )
6473 end
6574 end
75+ # rubocop:enable Metrics/AbcSize
76+ # rubocop:enable Metrics/CyclomaticComplexity
77+ # rubocop:enable Metrics/PerceivedComplexity
6678
6779 private
6880
@@ -77,14 +89,14 @@ def default_cover_image(entity, image_format)
7789 end
7890 end
7991
80- def default_profile_image ( entity )
92+ def default_profile_image ( entity , image_format )
8193 case entity . class . name
8294 when 'BetterTogether::Person'
83- ' profile_images/default_profile_image_person.jpg'
95+ " profile_images/default_profile_image_person.#{ image_format } "
8496 when 'BetterTogether::Community'
85- ' profile_images/default_profile_image_community.jpg'
97+ " profile_images/default_profile_image_community.#{ image_format } "
8698 else
87- ' profile_images/default_profile_image_generic.jpg'
99+ " profile_images/default_profile_image_generic.#{ image_format } "
88100 end
89101 end
90102 end
0 commit comments