【发布时间】:2011-09-30 07:35:25
【问题描述】:
我想用 html 代码替换图像,它必须是 php 函数的输出。 每当在 html 文档中找到图像标记时,都应将其传递给 php 函数并替换为 html 字符串。 我的期望如下。
index.htm 文件包含
hello <img src="image.jpg" /> 续句。
这个 image.jpg 被传递给 php 函数,比如
convert_pic('image.jpg');
所以 index.htm 的输出是
hello <div>....</div> 续句。
其中<div>....</div>是php函数convert_pic('image.jpg');的输出
所以<img src="image.jpg" /> 将被<?php convert_pic('image.jpg'); 替换
如何做到这一点,或任何其他可能实现这一目标?
【问题讨论】:
-
你能澄清更多你想要什么而不是图像标签吗?什么都没有?
-
实际上我希望网页中的所有图像都转换为一些 html 内容。
<img src="image.jpg" />应该是<div>some information about the image</div>不应该显示图像。而是将 div 内容显示在页面中 -
您想将
<div>标记附加到页面上找到的任何图像之前吗? -
你能告诉我们 convert_pic 方法会对那个图像做什么吗?返回值是多少?
-
convert_pic('image.jpg') 会将 jpg 图像转换为 html 内容。该内容以颜色代码格式显示图像。图像中的所有像素都转换为十六进制三元组(#ffffff)格式,然后显示在表格中。
标签: php html image function image-replacement