mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
25 lines
770 B
Elixir
25 lines
770 B
Elixir
|
defmodule PhilomenaProxy.Camo do
|
||
|
@moduledoc """
|
||
|
Image proxying utilities.
|
||
|
"""
|
||
|
|
||
|
@doc """
|
||
|
Convert a potentially untrusted external image URL into a trusted one
|
||
|
loaded through a gocamo proxy (specified by the environment).
|
||
|
|
||
|
Configuration is read from environment variables at runtime by Philomena.
|
||
|
|
||
|
config :philomena,
|
||
|
camo_host: System.get_env("CAMO_HOST"),
|
||
|
camo_key: System.get_env("CAMO_KEY"),
|
||
|
|
||
|
## Example
|
||
|
|
||
|
iex> PhilomenaProxy.Camo.image_url("https://example.org/img/view/2024/1/1/1.png")
|
||
|
"https://example.net/L5MqSmYq1ZEqiBGGvsvSDpILyJI/aHR0cHM6Ly9leGFtcGxlLm9yZy9pbWcvdmlldy8yMDI0LzEvMS8xLnBuZwo"
|
||
|
|
||
|
"""
|
||
|
@spec image_url(String.t()) :: String.t()
|
||
|
def image_url(input), do: Philomena.Native.camo_image_url(input)
|
||
|
end
|