【问题标题】:How to Fix "not allowed to load local resource" [Wordpress]如何修复“不允许加载本地资源”[Wordpress]
【发布时间】:2023-03-20 02:54:02
【问题描述】:

我正在使用 img 标签,但代码位于 php 块中。

<img class='client_image' src='" . get_stylesheet_directory() . "/assets/images/" . $print->client_images . "' alt='clientimage" . $clientindex . "' width='200' height ='200' />";

我一直被禁止加载本地资源,我不知道为什么。我正在使用预制的 wordpress 主题。我得到的只是损坏的图像图标。路径正确,文件名也正确。

【问题讨论】:

    标签: php html wordpress


    【解决方案1】:

    get_stylesheet_directory() 将返回您服务器上的路径,您需要 get_stylesheet_directory_uri() 代替:

    <img class='client_image' src='" . get_stylesheet_directory_uri() .    
    "/assets/images/" . $print->client_images . "' alt='clientimage" . 
    $clientindex . "' width='200' height ='200' />";
    

    【讨论】:

    • 哇,不知道有什么不同。谢谢。
    猜你喜欢
    • 2020-12-27
    • 2019-05-24
    • 1970-01-01
    • 2016-10-08
    • 2016-11-04
    • 2014-12-10
    • 1970-01-01
    相关资源
    最近更新 更多