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 Jun 27, 2017
1 parent 9616525 commit 9922759
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/services/concerns/iiif_thumbnail_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ def iiif_thumbnail_path(file_set, size)
)
end

def thumbnail?(_thumbnail)
true
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
Original file line number Diff line number Diff line change
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 9922759

Please sign in to comment.