From: Ivan Tashkinov Date: Tue, 1 Sep 2020 18:21:58 +0000 (+0300) Subject: [#2497] Fix for png media proxy preview response headers (content-type & content... X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=6ce28c409137972ee9b105b9d7ab4a0fd2a0d08b;p=akkoma [#2497] Fix for png media proxy preview response headers (content-type & content-disposition). --- diff --git a/lib/pleroma/web/media_proxy/media_proxy_controller.ex b/lib/pleroma/web/media_proxy/media_proxy_controller.ex index 2afcd861a..961c73666 100644 --- a/lib/pleroma/web/media_proxy/media_proxy_controller.ex +++ b/lib/pleroma/web/media_proxy/media_proxy_controller.ex @@ -67,7 +67,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do end end - # TODO: find a workaround so avatar_static and banner_static can work. + # TODO: find a workaround so avatar_static and header_static can work. # Those only permit GIFs for animation, so we have to permit a way to # allow those to get real static variants. defp handle_preview("image/gif" = _content_type, conn, url) do @@ -107,7 +107,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do } ) do conn - |> put_preview_response_headers() + |> put_preview_response_headers("image/png", "preview.png") |> send_resp(200, thumbnail_binary) else _ -> @@ -145,10 +145,10 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do end end - defp put_preview_response_headers(conn) do + defp put_preview_response_headers(conn, content_type \\ "image/jpeg", filename \\ "preview.jpg") do conn - |> put_resp_header("content-type", "image/jpeg") - |> put_resp_header("content-disposition", "inline; filename=\"preview.jpg\"") + |> put_resp_header("content-type", content_type) + |> put_resp_header("content-disposition", "inline; filename=\"#{filename}\"") |> put_resp_header("cache-control", "max-age=0, private, must-revalidate") end