Skip to content

Commit

Permalink
DEMAD-104 Video mp4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Blazquez Garcia committed Dec 18, 2020
1 parent 83615ce commit 7aa35e2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
6 changes: 3 additions & 3 deletions app/assets/javascripts/imageable.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ App.Imageable =
$(data.errorContainer).append(errors)

setPreview: (data) ->
# video_preview = "<div class='small-12 column text-center image-preview'><video width='320' height='240' controls><source src='#{data.result.attachment_url}' class='cached-image' type='video/mp4'>No se muestra el video</video></div>"
video_preview = "<video id='player' playsinline controls><source src='#{data.result.attachment_url}' type='video/mp4'></video>"

video_preview = "<video id='player' width='320' height='240' playsinline controls><source src='#{data.result.attachment_url}' type='video/mp4'></video>"
image_preview = "<div class='small-12 column text-center image-preview'><figure><img src='#{data.result.attachment_url}' class='cached-image'></figure></div>"
if $(data.preview).length > 0
if "mp4".indexOf(data.result.filename)
$(data.preview).replaceWith(video_preview)
$(data.preview).replaceWith(data.result.filename)
else
$(data.preview).replaceWith(image_preview)
else
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/banners/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%= javascript_include_tag 'swfobject' %>
<%= render "admin/shared/globalize_locales", resource: @banner %>
<%= translatable_form_for [:admin, @banner] do |f| %>
Expand Down
15 changes: 11 additions & 4 deletions app/views/images/_image.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<%= javascript_include_tag 'swfobject' %>
<div id="image" class="small-12 column text-center image-preview">
<figure>
<%= image_tag image.attachment.url(version),
class: image_class(image),
alt: image.title.unicode_normalize,
title: image.title.unicode_normalize %>
<% if image.attachment.url(version).include? "mp4" %>

<video id='player' width='320' height='240' playsinline controls><source src='<%= image.attachment.url %>' type='video/mp4'></video>

<%else%>
<%= image_tag image.attachment.url(version),
class: image_class(image),
alt: image.title.unicode_normalize,
title: image.title.unicode_normalize %>
<%end%>
<% if show_caption %>
<figcaption class="text-right">
<em><%= image.title.unicode_normalize %></em>
Expand Down
1 change: 1 addition & 0 deletions app/views/images/_image_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%= javascript_include_tag 'swfobject' %>
<div id="<%= dom_id(f.object) %>" class="image direct-upload nested-fields">
<%= f.hidden_field :id %>
<%= f.hidden_field :user_id, value: current_user.id %>
Expand Down
11 changes: 8 additions & 3 deletions app/views/welcome/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@

<% if header.image.present? %>
<div class="small-12 medium-6 column">
<%= image_tag(header.image_url(:large),
class: "margin",
alt: header.image.title) %>
<% if header.image.title.include? "mp4" %>
<video width='500' height='300' controls="controls" autoplay loop><source src="<%=header.image.attachment.url %>"/></video>
<%else%>
<%= image_tag(header.image_url(:large),
class: "margin",
alt: header.image.title) %>
<%end%>

</div>
<% end %>
</div>
Expand Down

0 comments on commit 7aa35e2

Please sign in to comment.