fix attachment links
This commit is contained in:
@ -111,7 +111,11 @@ defmodule SomethingErlang.AwfulApi.Thread do
|
|||||||
if class == "sa-smilie" do
|
if class == "sa-smilie" do
|
||||||
{"img", attrs, []}
|
{"img", attrs, []}
|
||||||
else
|
else
|
||||||
t_attrs = List.keyreplace(attrs, "class", 0, {"class", "img-responsive"})
|
t_attrs =
|
||||||
|
attrs
|
||||||
|
|> fix_attachment_links()
|
||||||
|
|> List.keyreplace("class", 0, {"class", "img-responsive"})
|
||||||
|
|
||||||
{"img", [{"loading", "lazy"} | t_attrs], []}
|
{"img", [{"loading", "lazy"} | t_attrs], []}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -194,4 +198,15 @@ defmodule SomethingErlang.AwfulApi.Thread do
|
|||||||
{"src", src}
|
{"src", src}
|
||||||
], []}
|
], []}
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
defp fix_attachment_links(attrs) do
|
||||||
|
{"src", src} = List.keyfind(attrs, "src", 0)
|
||||||
|
|
||||||
|
if String.starts_with?(src, "attachment.php") do
|
||||||
|
List.keyreplace(attrs, "src", 0, {"src", "https://forums.somethingawful.com/" <> src})
|
||||||
|
|> List.keydelete("alt", 0)
|
||||||
|
else
|
||||||
|
attrs
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user