Skip to content

Commit

Permalink
[i886] - Fix collection thumbnail fallback logic in Hyrax::ThumbnailP…
Browse files Browse the repository at this point in the history
…athServiceDecorator

The default work thumbnail was displaying even though the default collection thumbnail was set.

Issue:
- scientist-softserv/adventist_knapsack#886

- Updated #call method to use default_collection_image for collection resources when thumbnail_id is blank.
- Ensures collections without specific thumbnails use the site-wide default collection image instead of the default work image.
- Improved fallback logic to distinguish between collections and works, avoiding issues with collections displaying the work default image.
  • Loading branch information
ShanaLMoore committed Nov 14, 2024
1 parent 8cf3a6f commit 7e77eb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/services/hyrax/thumbnail_path_service_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ def call(object)
collection_thumbnail = CollectionBrandingInfo.where(collection_id: object.id.to_s, role: "thumbnail").first
return collection_thumbnail.local_path.gsub(Hyrax.config.branding_path.to_s, '/branding') if collection_thumbnail

return default_image if object.try(:thumbnail_id).blank?
if object.try(:thumbnail_id).blank?
return default_collection_image if object.try(:collection?)
return default_image
end

thumb = fetch_thumbnail(object)
return default_collection_image unless thumb

return call(thumb) unless thumb.file_set?
if audio?(thumb)
audio_image
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
config.force_ssl = true
config.ssl_options = {
redirect: {
exclude: -> request { request.path == '/healthz' }
exclude: ->(request) { request.path == '/healthz' }
}
}
# Use the lowest log level to ensure availability of diagnostic information
Expand Down

0 comments on commit 7e77eb6

Please sign in to comment.