From 33cc976068b866518d904beb406bf8894febab1a Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 30 Oct 2023 13:26:16 +0100 Subject: [PATCH] Allow adding links to images in Markdown campaigns --- CHANGELOG.md | 4 ++++ lib/keila/templates/html.ex | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b8b6e53..231e7c78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixed +- Markdown campaigns now allow adding links to images + + ## Version 0.12.6 ### Fixed diff --git a/lib/keila/templates/html.ex b/lib/keila/templates/html.ex index 51dee2e3..a94ab18c 100644 --- a/lib/keila/templates/html.ex +++ b/lib/keila/templates/html.ex @@ -210,6 +210,31 @@ defmodule Keila.Templates.Html do ]} end + defp do_apply_email_markup( + {"a", a_attrs, [{"table", _, [{"tr", _, [{"td", _, [{img, img_attrs, _}]}]}]}]} + ) do + {"table", [{"style", "width: 100%"}], + [ + {"tr", [{"class", "block--image"}], + [ + {"td", [], + [ + {"a", a_attrs, + [ + {"img", + img_attrs ++ + [ + {"width", "100%"}, + {"style", + "display:block; max-width:100%!important; height: auto!important;"}, + {"class", "g-img"} + ], []} + ]} + ]} + ]} + ]} + end + defp do_apply_email_markup({"img", img_attrs, _}) do {"table", [{"style", "width: 100%"}], [