【问题标题】:How to load images from https using the_field如何使用 the_field 从 https 加载图像
【发布时间】:2015-01-12 01:34:02
【问题描述】:

在 Wordpress 中,我有一行代码从 http 加载图像,我希望它从 https 加载它们。

<img class="img_notif" src="<?php the_field('small_img',$post->ID); ?>" />

这是它在页面中的作用:

<img class="img_notif" src="http://www.startupacademy.ro/wp-content/uploads/2013/06/antreprenor-de-succes-mic.jpg" />

如何更改代码以便强制 wordpress 从 https 加载图像?

【问题讨论】:

    标签: php ssl https


    【解决方案1】:

    由于 WP 似乎没有本地方式来执行此操作(我 震惊 &lt;/sarcasm&gt;)您可以使用 PHP 进行替换。将您的线路更改为

    <img class="img_notif" src="<?php str_replace('http', 'https', the_field('small_img',$post->ID)); ?>" />
    

    【讨论】:

    • 更改了线路,但无法正常工作。还是http
    猜你喜欢
    • 1970-01-01
    • 2021-10-22
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    • 2015-03-29
    • 1970-01-01
    • 2018-09-08
    • 2011-12-22
    相关资源
    最近更新 更多