【发布时间】:2014-04-15 14:33:04
【问题描述】:
我有一个这样的字符串:
<p>This is a paragraph with an image <img src='/url-to-img.jpg' style='height:100px;width:30px;float:right;'></p>
<p>This is another paragraph with an image <img src='/url-to-img.jpg' style='margin:10px;height:100px;width:30px;float:left;'></p>
这个字符串来自数据库,不幸的是,编辑器添加了这样的图像。
现在我想用 PHP 自动编辑这个:
<p>This is a paragraph with an image <img src='/url-to-img.jpg' style='height:100px;width:30px;float:right;' height=100 width=30 align='right'></p>
<p>This is another paragraph with an image <img src='/url-to-img.jpg' style='margin:10px;height:100px;width:30px;float:left;' height=100 width=30 align='left'></p>
我想从样式中获取高度和宽度并将它们添加到 img 标签中。
这可能吗?
(这样我的图像将显示替代文本,而不是 Outlook 中的小方块。我希望它显示为完整图像)
【问题讨论】:
-
嗯,为什么?目的是什么?
-
样式上已经定义好了,不需要再添加属性了。
-
用于时事通讯。当我使用样式时,它不会按应有的方式显示时事通讯,但是当我使用高度和宽度时,它会显示。
-
@prix 告诉 Outlook。当在样式中定义时,我的图像是一个小正方形,并且不显示替代文本。
标签: php html-parsing