diff --git a/app/services/concerns/iiif_thumbnail_paths.rb b/app/services/concerns/iiif_thumbnail_paths.rb index e33ccc353..405ff24e9 100644 --- a/app/services/concerns/iiif_thumbnail_paths.rb +++ b/app/services/concerns/iiif_thumbnail_paths.rb @@ -22,8 +22,13 @@ def iiif_thumbnail_path(file_set, size) ) end - def thumbnail?(_thumbnail) - true + # @param [FileSet] thumbnail the object that is the thumbnail + # @return [boolean] true when a thumbnail (either generated or a common asset) + # is expected to be available on the file system + def thumbnail?(thumbnail) + return true if thumbnail.image? || thumbnail.pdf? || thumbnail.office_document? || + thumbnail.audio? || thumbnail.video? + super(thumbnail) end end end diff --git a/spec/services/iiif_work_thumbnail_path_service_spec.rb b/spec/services/iiif_work_thumbnail_path_service_spec.rb index 3c2df0c6b..c3806c81b 100644 --- a/spec/services/iiif_work_thumbnail_path_service_spec.rb +++ b/spec/services/iiif_work_thumbnail_path_service_spec.rb @@ -39,5 +39,14 @@ it { is_expected.to eq '/downloads/s1784k724?file=thumbnail' } end + + context "with an unsupported mime type" do + let(:file) do + double(id: 's1/78/4k/72/s1784k724/files/6185235a-79b2-4c29-8c24-4d6ad9b11470', + mime_type: 'text/example') + end + + it { is_expected.to match %r{^\/assets\/work-\w+\.png$} } + end end end