1 defmodule Pleroma.HTML.Transform.MediaProxy do
2 @moduledoc "Transforms inline image URIs to use MediaProxy."
4 alias Pleroma.Web.MediaProxy
6 def before_scrub(html), do: html
8 def scrub_attribute(:img, {"src", "http" <> target}) do
16 def scrub_attribute(_tag, attribute), do: attribute
18 def scrub({:img, attributes, children}) do
21 |> Enum.map(fn attr -> scrub_attribute(:img, attr) end)
22 |> Enum.reject(&is_nil(&1))
24 {:img, attributes, children}
27 def scrub({:comment, _text, _children}), do: ""
29 def scrub({tag, attributes, children}), do: {tag, attributes, children}
30 def scrub({_tag, children}), do: children
31 def scrub(text), do: text