WordPress insecure content on ssl website

I am facing problems with insecure content being loaded on ssl wordpress, everything rest is fine, and all the links are under https, but few things we are echo-ing are not showing as https. I tried with plugin to fix insecure content but that didn’t work. Below is a code we use to get images which are showing as http instead of https. I wonder how can I force these images to load as https instead?

<?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

            }
        }
        ?>

And second one:

<?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

            }
        }
        ?>

Related posts

Leave a Reply

1 comment

  1. maybe you should strip URLs from http(s) protocols?

    <?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
    
            }
        }
    

    If I hadn’t made mistake in preg_replace REGEX you should get URLs like //your-site/.../image.png and this should solve your problem.