@@ -18,9 +18,6 @@ def fileboost_image_tag(asset, **options)
1818 # Generate the optimized URL
1919 optimized_url = fileboost_url_for ( asset , resize : resize_options )
2020
21- # Return empty string if no URL could be generated
22- return "" if optimized_url . blank?
23-
2421 # Use the optimized URL with Rails image_tag for consistency
2522 image_tag ( optimized_url , **options )
2623 end
@@ -36,16 +33,10 @@ def fileboost_image_tag(asset, **options)
3633 # fileboost_url_for(user.avatar.blob, resize: { w: 1200, h: 400, q: 85 })
3734 def fileboost_url_for ( asset , **options )
3835 # Validate that asset is an ActiveStorage object
39- unless valid_activestorage_asset? ( asset )
40- Rails . logger . error ( "[Fileboost] Invalid asset type #{ asset . class } . Only ActiveStorage objects are supported." ) if defined? ( Rails )
41- return nil
42- end
36+ raise ArgumentError , "Invalid asset type #{ asset . class } . Only ActiveStorage objects are supported." unless valid_activestorage_asset? ( asset )
4337
4438 # Validate configuration
45- unless Fileboost . config . valid?
46- log_configuration_warning
47- return nil
48- end
39+ raise Fileboost ::ConfigurationError , "Invalid Fileboost configuration" unless Fileboost . config . valid?
4940
5041 # Build the optimized URL
5142 Fileboost ::UrlBuilder . build_url ( asset , **options )
@@ -71,10 +62,13 @@ def fileboost_responsive_urls(asset, sizes, **base_options)
7162 sizes . each do |size_config |
7263 suffix = size_config [ :suffix ] || size_config [ "suffix" ]
7364 size_options = size_config . except ( :suffix , "suffix" )
74- combined_options = base_options . merge ( size_options )
65+
66+ # Merge size options into base resize options
67+ merged_resize_options = ( base_options [ :resize ] || { } ) . merge ( size_options )
68+ combined_options = base_options . merge ( resize : merged_resize_options )
7569
7670 url = fileboost_url_for ( asset , **combined_options )
77- urls [ suffix ] = url if url . present ?
71+ urls [ suffix ] = url if ! url . nil? && ! url . empty ?
7872 end
7973
8074 urls
@@ -91,17 +85,5 @@ def valid_activestorage_asset?(asset)
9185
9286 false
9387 end
94-
95- # Log configuration warnings
96- def log_configuration_warning
97- missing_configs = [ ]
98- missing_configs << "project_id" if Fileboost . config . project_id . blank?
99- missing_configs << "token" if Fileboost . config . token . blank?
100-
101- Rails . logger . warn (
102- "[Fileboost] Configuration incomplete. Missing: #{ missing_configs . join ( ', ' ) } . " \
103- "Set FILEBOOST_PROJECT_ID and FILEBOOST_TOKEN environment variables or configure them in your initializer."
104- ) if defined? ( Rails )
105- end
10688 end
10789end
0 commit comments