Skip to content

Commit

Permalink
fix: resolve movie cast images
Browse files Browse the repository at this point in the history
  • Loading branch information
trueChazza committed Jan 24, 2024
1 parent bfe0164 commit 2b99e75
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/media_server/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule MediaServer.Helpers do

def some_test({:ok, value}, "headshot") do
Enum.find(value, fn item -> item["coverType"] === "headshot" end)
|> another_test("url")
|> another_test("remoteUrl")
end

def some_test({:ok, value}, type) do
Expand Down
11 changes: 11 additions & 0 deletions lib/media_server_web/controllers/images_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ defmodule MediaServerWeb.ImagesController do
|> send_resp(200, body)
end

def index(conn, %{"url" => url, "type" => "proxy"}) do

{:ok, %HTTPoison.Response{status_code: 200, body: body}} =
HTTPoison.get(url)

conn
|> put_resp_header("content-type", "image/image")
|> put_resp_header("cache-control", "max-age=604800, public, must-revalidate")
|> send_resp(200, body)
end

def index(conn, %{"series" => id, "type" => "poster"}) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} =
HTTPoison.get(MediaServerWeb.Repositories.Series.get_url("mediacover/#{id}/poster-500.jpg"))
Expand Down
4 changes: 2 additions & 2 deletions lib/media_server_web/live/movies_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
title={item["personName"]}
subtitle=""
runtime=""
img_src={MediaServer.Helpers.get_headshot(item)}
link={MediaServer.Helpers.get_headshot(item)}
img_src={~p"/api/images?url=#{MediaServer.Helpers.get_headshot(item)}&type=proxy&token=#{@current_user.api_token.token}"}
link=""
width="80"
/>
<% end %>
Expand Down

0 comments on commit 2b99e75

Please sign in to comment.