Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在img src中调用函数_Php_Wordpress - Fatal编程技术网

Php 如何在img src中调用函数

Php 如何在img src中调用函数,php,wordpress,Php,Wordpress,我有下面的代码,但不想将图像编码为Base64,只需链接图像并使用相同的函数即可 <img src="data:image/png;base64,'.base64_encode(file_get_contents(get_field('email_logo', 'option')['url'])).'" alt="The Domain" /> 如何调用img src内部的函数?如果您只需要链接并且它是正确的: <img src="'.get_field('email_lo

我有下面的代码,但不想将图像编码为Base64,只需链接图像并使用相同的函数即可

<img src="data:image/png;base64,'.base64_encode(file_get_contents(get_field('email_logo', 'option')['url'])).'" alt="The Domain" />


如何调用img src内部的函数?

如果您只需要链接并且它是正确的:

<img src="'.get_field('email_logo', 'option')['url'].'"/>

您还没有向我们展示这段代码是如何连接到它周围的PHP的。假设前面有一个关闭的PHP块,而不是出现在打印或文本中

?>
...
<img src="data:image/png;base64,
  <?php 
     print base64_encode(file_get_contents(
         get_field('email_logo', 'option')['url']
         ));
  ?>'" alt="The Domain" />
?>
...
““alt=”域“/>

您不想对其进行编码,但您的代码仍然显示encode。我不确定是否理解。
base64\u encode()
文件获取内容()
不是html属性,你知道。;@Roko 80?你在哪里看到的?@user3647971如果你不知道提问者在问什么,回答问题是没有意义的。你添加的答案可能是正确的,但也可能是完全错误的,因为OP说“我不想将图像编码为Base64”“如何调用img src内部的函数?我看不到他可能提到的很多选项,除了显而易见的担忧是的,我只是想要链接,而不是编码图像。