php - 如何使用 the_field 从 https 加载图像

标签 php ssl https

在 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 加载图像?

最佳答案

由于 WP 似乎没有本地方法来执行此操作(我震惊 </sarcasm>),您只能使用 PHP 进行替换。将您的行更改为

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

关于php - 如何使用 the_field 从 https 加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27894164/

相关文章:

php - "Build"JS变量

php - 如何检查是否已输入 session_start?

JBoss 中的 SSL session 恢复

android - httpclient 和自签名证书的问题

asp.net - 如何在 http 和 https 之间共享 asp.net session

php - 使用 RESTful API 调用注册用户

php - SE 抓取 booth 目录和/index.php 文件 - 我怎样才能防止这种情况发生?

Java HTTPS 代理/重定向服务器

无需下载证书的 Java 和 HTTPS url 连接

ssl - 如何解决打算由 LAN 托管的站点的自签名 SSL 证书问题