diff --git a/app/forms/hyrax/forms/pcdm_collection_form_decorator.rb b/app/forms/hyrax/forms/pcdm_collection_form_decorator.rb index ee5e37753..a239b7b87 100644 --- a/app/forms/hyrax/forms/pcdm_collection_form_decorator.rb +++ b/app/forms/hyrax/forms/pcdm_collection_form_decorator.rb @@ -12,7 +12,7 @@ if thumbnail_info thumbnail_file = File.split(thumbnail_info.local_path).last alttext = thumbnail_info.alt_text - file_location = thumbnail_info.local_path + file_location = thumbnail_info.local_path.gsub('/app/samvera', '') relative_path = "/" + thumbnail_info.local_path.split("/")[-4..-1].join("/") { file: thumbnail_file, full_path: file_location, relative_path:, alttext: } else diff --git a/app/indexers/collection_resource_indexer.rb b/app/indexers/collection_resource_indexer.rb index fe2113e25..c5af47560 100644 --- a/app/indexers/collection_resource_indexer.rb +++ b/app/indexers/collection_resource_indexer.rb @@ -6,6 +6,7 @@ class CollectionResourceIndexer < Hyrax::Indexers::PcdmCollectionIndexer include Hyrax::Indexer(:basic_metadata) include Hyrax::Indexer(:bulkrax_metadata) include Hyrax::Indexer(:collection_resource) + include Hyrax::IndexesThumbnails def to_solr super.tap do |index_document| diff --git a/app/services/hyrax/indexes_thumbnails_decorator.rb b/app/services/hyrax/indexes_thumbnails_decorator.rb index 6620d5f97..d63983048 100644 --- a/app/services/hyrax/indexes_thumbnails_decorator.rb +++ b/app/services/hyrax/indexes_thumbnails_decorator.rb @@ -6,10 +6,11 @@ module Hyrax module IndexesThumbnailsDecorator # Returns the value for the thumbnail path to put into the solr document def thumbnail_path + object ||= @object || resource if object.try(:collection?) && UploadedCollectionThumbnailPathService.uploaded_thumbnail?(object) UploadedCollectionThumbnailPathService.call(object) else - super + CollectionResourceIndexer.thumbnail_path_service.call(object).gsub('/app/samvera', '') end end end diff --git a/lib/tasks/migrate_hyku_commons_collection_thumbnails_to_valkyrie.rake b/lib/tasks/migrate_hyku_commons_collection_thumbnails_to_valkyrie.rake index de8a4cd56..af9780514 100644 --- a/lib/tasks/migrate_hyku_commons_collection_thumbnails_to_valkyrie.rake +++ b/lib/tasks/migrate_hyku_commons_collection_thumbnails_to_valkyrie.rake @@ -7,7 +7,7 @@ namespace :hyku do Collection.find_each do |collection| # get collection solr document's thumbnail_path for each collection doc = collection.to_solr - original_thumbnail_path = File.join(Rails.public_path, doc['thumbnail_path_ss']) + original_thumbnail_path = File.join('public/branding/', doc['thumbnail_path_ss']) next unless File.exist?(original_thumbnail_path)