obj storage prep: skip generating urls for symlink version targets

This commit is contained in:
byte[] 2021-04-17 22:28:03 -04:00
parent d49fadf15b
commit de8001a1ff
2 changed files with 15 additions and 10 deletions

View file

@ -22,6 +22,12 @@ defmodule Philomena.Images.Thumbnailer do
full: nil
]
def thumbnail_versions do
Enum.filter(@versions, fn {_name, dimensions} ->
not is_nil(dimensions)
end)
end
def thumbnail_urls(image, hidden_key) do
Path.join([image_thumb_dir(image), "*"])
|> Path.wildcard()

View file

@ -2,6 +2,7 @@ defmodule PhilomenaWeb.ImageView do
use PhilomenaWeb, :view
alias Philomena.Tags.Tag
alias Philomena.Images.Thumbnailer
def show_vote_counts?(%{hide_vote_counts: true}), do: false
def show_vote_counts?(_user), do: true
@ -45,16 +46,14 @@ defmodule PhilomenaWeb.ImageView do
end
def thumb_urls(image, show_hidden) do
%{
thumb_tiny: thumb_url(image, show_hidden, :thumb_tiny),
thumb_small: thumb_url(image, show_hidden, :thumb_small),
thumb: thumb_url(image, show_hidden, :thumb),
small: thumb_url(image, show_hidden, :small),
medium: thumb_url(image, show_hidden, :medium),
large: thumb_url(image, show_hidden, :large),
tall: thumb_url(image, show_hidden, :tall),
full: pretty_url(image, true, false)
}
Thumbnailer.thumbnail_versions()
|> Map.new(fn {name, {width, height}} ->
if image.image_width > width or image.image_height > height do
{name, thumb_url(image, show_hidden, name)}
else
{name, thumb_url(image, show_hidden, :full)}
end
end)
|> append_full_url(image, show_hidden)
|> append_gif_urls(image, show_hidden)
end