fix(post): sort media files by name
This commit is contained in:
parent
e635454b2e
commit
4851b9bf7c
1 changed files with 10 additions and 2 deletions
|
@ -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)
|
||||
|
||||
|
|
Reference in a new issue