diff --git a/lib/bdfr_browser/http/plug.ex b/lib/bdfr_browser/http/plug.ex index 33dc87b..c830321 100644 --- a/lib/bdfr_browser/http/plug.ex +++ b/lib/bdfr_browser/http/plug.ex @@ -208,11 +208,19 @@ defmodule BdfrBrowser.HTTP.Plug do post_vid = "#{post}*.{mp4,MP4}" %{ - images: [post_dir, post_img] |> Path.join() |> Path.wildcard() |> Enum.map(&media_path/1), - videos: [post_dir, post_vid] |> Path.join() |> Path.wildcard() |> Enum.map(&media_path/1) + images: post_media_for_type(post_dir, post_img), + videos: post_media_for_type(post_dir, post_vid) } end + defp post_media_for_type(post_dir, post_type) do + [post_dir, post_type] + |> Path.join() + |> Path.wildcard() + |> Enum.map(&media_path/1) + |> Enum.sort() + end + defp media_path(full_path) do base_directory = Application.fetch_env!(:bdfr_browser, :base_directory)