show media preview for media files in file show view
test plan: * upload a media file (video/audio) to a course * when either: * linking the file to a module item and clicking on the item link * or, directly going to the file show page (e.g. '/courses/:course_id/files/:attachment_id') * confirm that the media preview appears (rather than a failed document preview), just as on the main 'Files' page fixes #CNVS-2529 Change-Id: Ic8701c28a7ea0382de84e36fc363c0cff8cc2ac6 Reviewed-on: https://gerrit.instructure.com/21616 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> QA-Review: Clare Strong <clare@instructure.com>
This commit is contained in:
parent
c041c4383d
commit
92867eaed4
|
@ -0,0 +1,8 @@
|
|||
require [
|
||||
'jquery'
|
||||
'media_comments'
|
||||
], ($) ->
|
||||
|
||||
$preview = $("#media_preview")
|
||||
data = $preview.data()
|
||||
$preview.mediaComment('show_inline', 'maybe', data.type, data.download_url)
|
|
@ -45,4 +45,10 @@ module AttachmentHelper
|
|||
end
|
||||
attrs.inject("") { |s,(attr,val)| s << "data-#{attr}=#{val} " }
|
||||
end
|
||||
|
||||
def media_preview_attributes(attachment, attrs={})
|
||||
attrs[:type] = attachment.content_type.match(/video/) ? 'video' : 'audio'
|
||||
attrs[:download_url] = context_url(attachment.context, :context_file_download_url, attachment.id)
|
||||
attrs.inject("") { |s,(attr,val)| s << "data-#{attr}=#{val} " }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,6 +35,13 @@
|
|||
<% elsif @attachment.content_type && @attachment.content_type.match(/\Aimage\//) %>
|
||||
<h2><%= @attachment.display_name %></h2>
|
||||
<%= link_to(image_tag(download_url, :alt => @attachment.display_name), download_url) %>
|
||||
<% elsif @attachment.content_type && @attachment.content_type.match(/\Avideo\/|audio\//) %>
|
||||
<% js_bundle :file_preview %>
|
||||
<h2><%= @attachment.display_name %></h2>
|
||||
<div id="media_preview" <%= media_preview_attributes(@attachment) %>></div>
|
||||
<span style="font-size: 1.2em;">
|
||||
<%= link_to "Download #{@attachment.display_name}", download_url %>
|
||||
</span> (<%= @attachment.readable_size %>)
|
||||
<% else %>
|
||||
<% js_bundle :file_show %>
|
||||
<h2><%= @attachment.display_name %></h2>
|
||||
|
|
Loading…
Reference in New Issue