Fix srcsets overriding rewritten image srcs
This commit is contained in:
parent
852db1520f
commit
b9be2879ed
|
@ -158,6 +158,16 @@ defmodule Frenzy.Pipeline.ScrapeStage do
|
||||||
attr
|
attr
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
has_src = Enum.find(new_attrs, fn {name, _} -> name == "src" end)
|
||||||
|
|
||||||
|
# remove srcsets because our transformation only applies to the src attribute, so that should always be used
|
||||||
|
new_attrs =
|
||||||
|
if has_src do
|
||||||
|
Enum.reject(new_attrs, fn {name, _} -> name == "srcset" end)
|
||||||
|
else
|
||||||
|
new_attrs
|
||||||
|
end
|
||||||
|
|
||||||
{"img", new_attrs}
|
{"img", new_attrs}
|
||||||
|
|
||||||
elem ->
|
elem ->
|
||||||
|
@ -191,5 +201,5 @@ defmodule Frenzy.Pipeline.ScrapeStage do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp image_to_data_uri(src, _site_uri, false), do: src
|
defp image_to_data_uri(src, site_uri, false), do: to_string(URI.merge(site_uri, src))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue