Open jbaiter opened 2 years ago
Ah I see the problem, yes so maybe if it created a list of the content resources first, then it could pick from those. I think the general problem is that we need to check all possibilities before being able to choose the best one for a thumbnail.
There are a load of shortcuts, but I had hoped that this thumbnail helper would be a definitive way to always find a thumbnail if one existed. Will have a look over the weekend
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-lwux3gI 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 anAnnotation
, it assumes that the first body item is an Image that can be passed toimageServiceLoader.getThumbnailFromResource
: https://github.com/IIIF-Commons/vault-helpers/blob/8a14efa1fdaf2e31f87a926e515efb7bf3631bc3/src/thumbnail.ts#L72-L88I 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.