Skip to content

Commit

Permalink
Merge pull request #213 from scientist-softserv/add-guard-to-manifest…
Browse files Browse the repository at this point in the history
…-metadata-method

Add guard to method
  • Loading branch information
laritakr authored Apr 7, 2023
2 parents 53ecfeb + c5b8418 commit 487cf53
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/services/iiif_print/manifest_builder_service_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,12 @@ def sanitize_v3(hash:, presenter:)

def apply_metadata_to_canvas(canvas:, presenter:)
return if @child_works.empty?

parent_and_child_solr_hits = parent_and_child_solr_hits(presenter)
# uses the 'id' property for v3 manifest and `@id' for v2, which is a URL that contains the FileSet id
file_set_id = (canvas['id'] || canvas['@id']).split('/').last
# finds the image that the FileSet is attached to and creates metadata on that canvas
image = parent_and_child_solr_hits.find { |doc| doc[:member_ids_ssim]&.include?(file_set_id) }

return unless image
canvas_metadata = IiifPrint.manifest_metadata_from(work: image, presenter: presenter)
canvas['metadata'] = canvas_metadata
end
Expand Down

0 comments on commit 487cf53

Please sign in to comment.