Skip to content

Commit

Permalink
Merge pull request #5969 from avalonmediasystem/video_icon
Browse files Browse the repository at this point in the history
Display video icon when video lacks thumbnail
  • Loading branch information
masaball authored Aug 19, 2024
2 parents f2acb4d + 0abfacf commit 60f89bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/master_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ def get_frame
end
if content
send_data content, :filename => "#{params[:type]}-#{@master_file.id.split(':')[1]}", :disposition => :inline, :type => mimeType
elsif @master_file.is_video?
redirect_to ActionController::Base.helpers.asset_path('video_icon.png')
else
redirect_to ActionController::Base.helpers.asset_path('audio_icon.png')
end
Expand Down
14 changes: 14 additions & 0 deletions spec/controllers/master_files_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,20 @@ class << file
expect(response.body).to eq('fake image content')
expect(response.headers['Content-Type']).to eq('image/jpeg')
end

context "video without thumbnail" do
subject(:mf) { FactoryBot.create(:master_file, :with_media_object) }
it "returns video_icon.png" do
expect(get :get_frame, params: { id: mf.id, type: 'thumbnail', size: 'bar' }).to redirect_to(ActionController::Base.helpers.asset_path('video_icon.png'))
end
end

context "audio" do
subject(:mf) { FactoryBot.create(:master_file, :audio, :with_media_object) }
it "returns audio_icon.png" do
expect(get :get_frame, params: { id: mf.id, type: 'thumbnail', size: 'bar' }).to redirect_to(ActionController::Base.helpers.asset_path('audio_icon.png'))
end
end
end

context 'read from solr' do
Expand Down

0 comments on commit 60f89bc

Please sign in to comment.