Skip to content

Thumbnail helper doesn't handle 'Choice' resources correctly #7

@jbaiter

Description

@jbaiter

When attempting to load the thumbnail for the Manifest at https://iiif.io/api/cookbook/recipe/0033-choice/manifest.json, getBestThumbnailAtSize is unable to find one:
https://codesandbox.io/s/vault-helpers-forked-lwux3g

I assume it's due to the fact that the Manifest's sole Canvas has an Annotation with a Choice body that has two different images.

Looking through the code, it seems to me that getBestThumbnailAtSize is missing a level of recursion. When it encounters an Annotation, it assumes that the first body item is an Image that can be passed to imageServiceLoader.getThumbnailFromResource: https://github.com/IIIF-Commons/vault-helpers/blob/8a14efa1fdaf2e31f87a926e515efb7bf3631bc3/src/thumbnail.ts#L72-L88

I think it should instead check the type of the body item and recurse if it's a Choice, so it will hit the branch at https://github.com/IIIF-Commons/vault-helpers/blob/8a14efa1fdaf2e31f87a926e515efb7bf3631bc3/src/thumbnail.ts#L113-L117, which should do the right thing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions