首页 > 解决方案 > 如何将多个标签更改为?

问题描述

<?php

$content_description = '<p><strong><em>They have added their own unique spin to marketing technology and convinced us that their refreshing understanding of the whys and wherefores of this rapidly growing industry is just one of the several ways to look at business. In this feature, we bring you the views of key executives who discuss how their ‘being’ pours into their professional personas&nbsp; </em></strong></p>

<p style="text-align: center;"><span style="color:#FF8C00;font-size:21px;"><strong>How does being a woman as a part of an exponentially explosive marketing tech space help you to be better equipped to understand this constantly evolving sector through your unique perspective?</strong></span></p>

<p><span style="color:#000080;"><strong>Nikki Nixon, Director #FlipMyFunnel at Terminus</strong></span></p>

<p><img alt="" class="lazy" src="https://images.martechadvisor.com/images/uploads/ckimages/images/nikki_nixon_terminus_58c049be4adc8.jpg" style="float: left; width: 125px; height: 107px; margin: 3px;" />“Being a woman in marketing tech, coupled with being an introvert, has given me tremendous advantages. I’ve had the opportunity to grow two software companies in the space and be uniquely empathetic along the way. My introversion allows me to think critically about the pros and cons of a given tool beyond the surface sales pitch. It allows me to dig deeper and ask questions to determine if the tool will really solve my needs.”&lt;/p>

<p><span style="color:#000080;"><strong>Jen Spencer, Vice President of Sales and Marketing at Allbound</strong></span></p>

<p><img alt="" class="lazy" src="https://images.martechadvisor.com/images/uploads/ckimages/images/jen_square_58c049dae10c2.jpg" style="float: right; width: 125px; height: 103px; margin: 3px;" />“Since I’m a woman, and I’ve always been a woman, I don’t know any other way of being. I can’t begin to assume I know what makes me as a woman better suited to lead a sales and marketing team at a SaaS company than a man – except maybe that having had twins, I know I have more stamina than most. Getting by on 4 hours of sleep a night? No problem! Getting those 4 hours of sleep in 1 hour increments over a 12-hour period? I. Will. Win.<br />
?>

我需要将所有 Img 标签替换<amp-img>为所有图像的格式应该看起来像。<amp-img src="/img/amp.jpg" width="1080" height="610" layout="responsive" alt="AMP"></amp-img>

标签: phphtmlimageamp-html

解决方案


您可以使用以下方法实现您的目标

  1. 删除内容的内联 css,因为 amp 不支持内联 css
  2. <img>标签转换为<amp-img>标签,同时添加高度、宽度和布局(amp 要求)

这是工作网址:单击此处

代码 :

<?php
$content_description = '<p><strong><em>They have added their own unique spin to marketing technology and convinced us that their refreshing understanding of the whys and wherefores of this rapidly growing industry is just one of the several ways to look at business. In this feature, we bring you the views of key executives who discuss how their ‘being’ pours into their professional personas&nbsp; </em></strong></p>

<p style="text-align: center;"><span style="color:#FF8C00;font-size:21px;"><strong>How does being a woman as a part of an exponentially explosive marketing tech space help you to be better equipped to understand this constantly evolving sector through your unique perspective?</strong></span></p>

<p><span style="color:#000080;"><strong>Nikki Nixon, Director #FlipMyFunnel at Terminus</strong></span></p>

<p><img alt="" class="lazy" src="https://images.martechadvisor.com/images/uploads/ckimages/images/nikki_nixon_terminus_58c049be4adc8.jpg" style="float: left; width: 125px; height: 107px; margin: 3px;" />“Being a woman in marketing tech, coupled with being an introvert, has given me tremendous advantages. I’ve had the opportunity to grow two software companies in the space and be uniquely empathetic along the way. My introversion allows me to think critically about the pros and cons of a given tool beyond the surface sales pitch. It allows me to dig deeper and ask questions to determine if the tool will really solve my needs.”&lt;/p>

<p><span style="color:#000080;"><strong>Jen Spencer, Vice President of Sales and Marketing at Allbound</strong></span></p>

<p><img alt="" class="lazy" src="https://images.martechadvisor.com/images/uploads/ckimages/images/jen_square_58c049dae10c2.jpg" style="float: right; width: 125px; height: 103px; margin: 3px;" />“Since I’m a woman, and I’ve always been a woman, I don’t know any other way of being. I can’t begin to assume I know what makes me as a woman better suited to lead a sales and marketing team at a SaaS company than a man – except maybe that having had twins, I know I have more stamina than most. Getting by on 4 hours of sleep a night? No problem! Getting those 4 hours of sleep in 1 hour increments over a 12-hour period? I. Will. Win.<br />';
$content = preg_replace('/style=[^>]*/', '', $content_description);
$html = preg_replace('/<img(.*?)\/?>/', '<amp-img$1 width="1080" height="610" layout="responsive" alt="AMP"></amp-img>',$content);
echo $html;
?>

推荐阅读