Skip to content

Commit

Permalink
Add guard to method
Browse files Browse the repository at this point in the history
Previously we got an error because of calling `IiifPrint.manifest_metadata_from(work: image, presenter: presenter)` when image was nil.
  • Loading branch information
LaRita Robinson committed Apr 7, 2023
1 parent 53ecfeb commit c5b8418
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 c5b8418

Please sign in to comment.