当我保存时,SendGrid通过更改我的html模板“帮助”我?

前端之家收集整理的这篇文章主要介绍了当我保存时,SendGrid通过更改我的html模板“帮助”我?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在SendGrid中创建一个默认模板,用于它们的事务api.然后我添加一个带浮动的img链接:就在它里面.当我在他们的编辑器中点击“save”时,它会从我的图像中擦除浮动并在其中插入一个名为sg-image的新类.当然,这会弄乱我的风格.有人见过这个或知道为什么Sendgrid与我的模板一起?我找不到任何关于它的文档,他们的支持团队对我的错误报告没有反应.

之前:

<html>
<head>
	<title></title>
</head>
<body>
<div>&lt;%body%&gt;</div>
	<a href="%STORYURL1%" style="color:#333332;text-decoration:none">
	  <img src="%STORYPIC1%" height="122" style="float:right !important; border:1px solid #e5e5e5; margin-left:7px;"></a>

</body>
</html>

<html>
<head>
	<title></title>
</head>
<body>
<div>&lt;%body%&gt;</div>

<div><a href="%STORYURL1%" style="color:#333332;text-decoration:none"><span class="sg-image" data-imagelibrary="%7B%22width%22%3A0%2C%22height%22%3A%22122%22%2C%22alignment%22%3A%22%22%2C%22border%22%3A1%2C%22src%22%3A%22%25STORYPIC1%25%22%2C%22classes%22%3A%7B%22sg-image%22%3A1%7D%7D"><img height="122" src="%STORYPIC1%" style="border: 1px solid transparent; margin-left: 7px; height: 122px;" /></span></a></div>
</body>
</html>

解决方法

几个月来我们一直在经历这个问题,最终没有使用他们糟糕的模板系统并构建我们自己的模板系统.无论如何,他们终于承认了这个问题并回来了解决方案/解决方案.

他们提供的解决方案:

你好,
这是工程师提供的解决方案:
例:

<td><span class="sg-image" data-imagelibrary="%7B%22width%22%3A%22160%22%2C%22height%22%3A%22200%22%2C%22alt_text%22%3A%22%7B%7B%20uc%5B2%5D%5B%27uniqueSymbol%27%5D%20%7D%7D%20-%20%7B%7B%20uc%5B2%5D%5B%27name%27%5D%20%7D%7D%22%2C%22alignment%22%3A%22center%22%2C%22border%22%3A0%2C%22src%22%3A%22http%3A//cdn.fakewebsite.st/image/%7B%7B%20uc%5B2%5D%5B%27uniqueSymbol%27%5D%7Creplace%28%7B%27%3A%27%3A%20%27-%27%7D%29%20%7D%7D.png%22%2C%22classes%22%3A%7B%22sg-image%22%3A1%7D%7D" style="float: none; display: block; text-align: center;"><a href="https://fakewebsite.st/?utm_source=blah&amp;utm_medium=email&amp;utm_campaign=v1" target="_blank"><img alt=" - " height="200" src="http://cdn.fakewebsite.st/image/{{ uc[2]['uniqueSymbol']|replace({':': '-'}) }}.png" style="width: 160px; height: 200px;" width="160" /></a></span></td>

看看“data-imagelibrary”.这是关于应该使用的图像的URL编码信息.
数据imagelibrary:

%7B%22width%22%3A%22160%22%2C%22height%22%3A%22200%22%2C%22alt_text%22%3A%22%7B%7B%20uc%5B2%5D%5B%27uniqueSymbol%27%5D%20%7D%7D%20-%20%7B%7B%20uc%5B2%5D%5B%27name%27%5D%20%7D%7D%22%2C%22alignment%22%3A%22center%22%2C%22border%22%3A0%2C%22src%22%3A%22http%3A//cdn.fakewebsite.st/image/%7B%7B%20uc%5B2%5D%5B%27uniqueSymbol%27%5D%7Creplace%28%7B%27%3A%27%3A%20%27-%27%7D%29%20%7D%7D.png%22%2C%22classes%22%3A%7B%22sg-image%22%3A1%7D%7D

data-imagelibrary已解码:

{"width":"160","height":"200","alt_text":" - ","alignment":"center","border":0,"src":"http://cdn.fakewebsite.st/image/{{ uc[2]['uniqueSymbol']|replace({':': '-'}) }}.png","classes":{"sg-image":1}}
You can make changes to this data and then re-encode:
{"width":"160","src":"http://cdn.fakewebsite.st/image/{{ hc[2]['uniqueSymbol']|replace({':': '-'}) }}.png","classes":{"sg-image":1}}

重新编码:

%7B%22width%22%3A%22160%22%2C%22height%22%3A%22200%22%2C%22alt_text%22%3A%22%7B%7B%20hc%5B2%5D%5B%27uniqueSymbol%27%5D%20%7D%7D%20-%20%7B%7B%20hc%5B2%5D%5B%27name%27%5D%20%7D%7D%22%2C%22alignment%22%3A%22center%22%2C%22border%22%3A0%2C%22src%22%3A%22http%3A%2F%2Fcdn.fakewebsite.st%2Fimage%2F%7B%7B%20hc%5B2%5D%5B%27uniqueSymbol%27%5D%7Creplace(%7B%27%3A%27%3A%20%27-%27%7D)%20%7D%7D.png%22%2C%22classes%22%3A%7B%22sg-image%22%3A1%7D%7D

您可以将URL编码信息放回HTML中,它应该更改代码.
如果这有用,请告诉我.

问候,

SendGrid支持

猜你在找的HTML相关文章