general video improvements

pull/5300/head
cen1 3 years ago committed by Viktor Baranov
parent ba8e41c018
commit d74c1f223f
  1. 8
      apps/block_scout_web/lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex
  2. 2
      apps/block_scout_web/lib/block_scout_web/templates/tokens/inventory/_token.html.eex
  3. 25
      apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex

@ -61,12 +61,12 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="erc721-media" > <div class="erc721-media" >
<%= if media_type(media_src(@token_instance.instance)) == "video" do %> <%= if media_type(media_src_detail(@token_instance.instance)) == "video" do %>
<video autoplay style="width: 100%;"> <video controls autoplay playsinline style="width: 100%;">
<source src=<%= media_src(@token_instance.instance) %> type="video/mp4"> <source src=<%= media_src_detail(@token_instance.instance) %> type="video/mp4">
</video> </video>
<% else %> <% else %>
<img src=<%= media_src(@token_instance.instance) %> /> <img src=<%= media_src_detail(@token_instance.instance) %> />
<% end %> <% end %>
</div> </div>
</div> </div>

@ -46,7 +46,7 @@
<!-- substitute the span with <img class="tile-image" /> to token with images --> <!-- substitute the span with <img class="tile-image" /> to token with images -->
<div class="inventory-erc721-media" > <div class="inventory-erc721-media" >
<%= if media_type(media_src(@token_transfer.instance)) == "video" do %> <%= if media_type(media_src(@token_transfer.instance)) == "video" do %>
<video autoplay> <video>
<source src=<%= media_src(@token_transfer.instance) %> type="video/mp4"> <source src=<%= media_src(@token_transfer.instance) %> type="video/mp4">
</video> </video>
<% else %> <% else %>

@ -44,6 +44,31 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
if String.trim(result) == "", do: media_src(nil), else: result if String.trim(result) == "", do: media_src(nil), else: result
end end
def media_src_detail(nil), do: @stub_image
def media_src_detail(instance) do
result =
cond do
instance.metadata && instance.metadata["animation_url"] ->
retrieve_image(instance.metadata["animation_url"])
instance.metadata && instance.metadata["image_url"] ->
retrieve_image(instance.metadata["image_url"])
instance.metadata && instance.metadata["image"] ->
retrieve_image(instance.metadata["image"])
instance.metadata && instance.metadata["properties"]["image"]["description"] ->
instance.metadata["properties"]["image"]["description"]
true ->
media_src_detail(nil)
end
if String.trim(result) == "", do: media_src_detail(nil), else: result
end
def media_type(media_src) when not is_nil(media_src) do def media_type(media_src) when not is_nil(media_src) do
ext = media_src |> Path.extname() |> String.trim() ext = media_src |> Path.extname() |> String.trim()

Loading…
Cancel
Save