|
|
|
@ -26,49 +26,32 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do |
|
|
|
|
def media_src(nil), do: @stub_image |
|
|
|
|
|
|
|
|
|
def media_src(instance) do |
|
|
|
|
result = |
|
|
|
|
cond do |
|
|
|
|
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(nil) |
|
|
|
|
end |
|
|
|
|
result = get_media_src(instance.metadata) |
|
|
|
|
|
|
|
|
|
if String.trim(result) == "", do: media_src(nil), else: result |
|
|
|
|
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"]) |
|
|
|
|
defp get_media_src(nil), do: media_src(nil) |
|
|
|
|
|
|
|
|
|
instance.metadata && instance.metadata["image_url"] -> |
|
|
|
|
retrieve_image(instance.metadata["image_url"]) |
|
|
|
|
defp get_media_src(metadata) do |
|
|
|
|
cond do |
|
|
|
|
metadata["animation_url"] -> |
|
|
|
|
retrieve_image(metadata["animation_url"]) |
|
|
|
|
|
|
|
|
|
instance.metadata && instance.metadata["image"] -> |
|
|
|
|
retrieve_image(instance.metadata["image"]) |
|
|
|
|
metadata["image_url"] -> |
|
|
|
|
retrieve_image(metadata["image_url"]) |
|
|
|
|
|
|
|
|
|
instance.metadata && instance.metadata["properties"]["image"]["description"] -> |
|
|
|
|
instance.metadata["properties"]["image"]["description"] |
|
|
|
|
metadata["image"] -> |
|
|
|
|
retrieve_image(metadata["image"]) |
|
|
|
|
|
|
|
|
|
true -> |
|
|
|
|
media_src_detail(nil) |
|
|
|
|
end |
|
|
|
|
metadata["properties"]["image"]["description"] -> |
|
|
|
|
metadata["properties"]["image"]["description"] |
|
|
|
|
|
|
|
|
|
if String.trim(result) == "", do: media_src_detail(nil), else: result |
|
|
|
|
true -> |
|
|
|
|
media_src(nil) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def media_type(media_src) when not is_nil(media_src) do |
|
|
|
|
ext = media_src |> Path.extname() |> String.trim() |
|
|
|
|
|
|
|
|
|