Skip to content

Commit

Permalink
Do not assume that everything has a thumbnail available.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlpierce committed Aug 30, 2017
1 parent 9616525 commit 1f28421
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/services/concerns/iiif_thumbnail_paths.rb
Expand Up @@ -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
9 changes: 9 additions & 0 deletions spec/services/iiif_work_thumbnail_path_service_spec.rb
Expand Up @@ -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

0 comments on commit 1f28421

Please sign in to comment.