Adds thumbnails as episode-level images for podcasts (#201)
This commit is contained in:
@@ -2,8 +2,9 @@ defmodule PinchflatWeb.Podcasts.PodcastController do
|
||||
use PinchflatWeb, :controller
|
||||
|
||||
alias Pinchflat.Repo
|
||||
alias Pinchflat.Media.MediaQuery
|
||||
alias Pinchflat.Sources.Source
|
||||
alias Pinchflat.Media.MediaItem
|
||||
alias Pinchflat.Media.MediaQuery
|
||||
alias Pinchflat.Podcasts.RssFeedBuilder
|
||||
alias Pinchflat.Podcasts.PodcastHelpers
|
||||
|
||||
@@ -40,4 +41,16 @@ defmodule PinchflatWeb.Podcasts.PodcastController do
|
||||
|> send_file(200, filepath)
|
||||
end
|
||||
end
|
||||
|
||||
def episode_image(conn, %{"uuid" => uuid}) do
|
||||
media_item = Repo.get_by!(MediaItem, uuid: uuid)
|
||||
|
||||
if media_item.thumbnail_filepath && File.exists?(media_item.thumbnail_filepath) do
|
||||
conn
|
||||
|> put_resp_content_type(MIME.from_path(media_item.thumbnail_filepath))
|
||||
|> send_file(200, media_item.thumbnail_filepath)
|
||||
else
|
||||
send_resp(conn, 404, "Image not found")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user