Class: ActiveStorage::Previewer::VideoPreviewer

Inherits:
ActiveStorage::Previewer show all
Defined in:
activestorage/lib/active_storage/previewer/video_previewer.rb

Instance Attribute Summary

Attributes inherited from ActiveStorage::Previewer

#blob

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveStorage::Previewer

#initialize

Constructor Details

This class inherits a constructor from ActiveStorage::Previewer

Class Method Details

.accept?(blob) ⇒ Boolean


5
6
7
# File 'activestorage/lib/active_storage/previewer/video_previewer.rb', line 5

def self.accept?(blob)
  blob.video?
end

Instance Method Details

#preview(**options) ⇒ Object


9
10
11
12
13
14
15
# File 'activestorage/lib/active_storage/previewer/video_previewer.rb', line 9

def preview(**options)
  download_blob_to_tempfile do |input|
    draw_relevant_frame_from input do |output|
      yield io: output, filename: "#{blob.filename.base}.jpg", content_type: "image/jpeg", **options
    end
  end
end