ssl网站上的WordPress不安全内容

时间:2014-12-05 11:07:55

标签: php wordpress ssl

我面临着在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

            }
        }
        ?>

1 个答案:

答案 0 :(得分:0)

也许你应该从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

        }
    }

如果我在preg_replace REGEX中没有出错,您应该获得//your-site/.../image.png这样的网址,这样可以解决您的问题。