在 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/