我遇到了在ssl wordpress上加载不安全内容的问题,其余一切正常,所有链接都在https下,但是我们回显的很少的东西没有显示为https。我尝试使用插件修复不安全的内容,但这不起作用。下面是我们用来获取显示为http而不是https的图像的代码。我想知道如何强制这些图像加载为 https?
<?php
$galleryImages = get_post_meta($post->ID, 'atak_portfolio_gallaryImages', true);
if(is_array($galleryImages)){
foreach($galleryImages as $galleryImage)
{
?>
<a href="<?php echo $galleryImage; ?>">
<img class="alignnone size-full wp-image-1232" src="<?php echo $galleryImage; ?>" alt="project10-4" rel="lightbox" width="1024" height="673">
</a>
<?php
}
}
?>
第二个:
<?php
$galleryImages = get_post_meta($post->ID, 'atak_portfolio_gallaryImages', true);
if(is_array($galleryImages)){
foreach($galleryImages as $galleryImage)
{
?>
<a href="<?php echo $galleryImage; ?>">
<img class="alignnone size-full wp-image-1232" src="<?php echo $galleryImage; ?>" alt="project10-4" rel="lightbox" title="Atak Interactive Portfolio" width="1024" height="673">
</a>
<?php
}
}
?>
也许你应该从http(s)协议中删除URL?
<?php
$galleryImages = get_post_meta($post->ID, 'atak_portfolio_gallaryImages', true);
if(is_array($galleryImages)){
foreach($galleryImages as $galleryImage)
{
$galleryImage = preg_replace( '#http[s]?:#i', '', $galleryImage );
?>
<a href="<?php echo $galleryImage; ?>">
<img class="alignnone size-full wp-image-1232" src="<?php echo $galleryImage; ?>" alt="project10-4" rel="lightbox" title="Atak Interactive Portfolio" width="1024" height="673">
</a>
<?php
}
}
如果我在 REGEX preg_replace没有犯错,您应该获得像 //your-site/.../image.png
这样的 URL,这应该可以解决您的问题。