Issue with the wpv-post-featured-image shortcode after moving site to SSL

Resolved

Reported for: Toolset Views 1.11.1

Resolved in: Toolset Views 2.2

Symptoms

If you have moved your site to SSL (i.e. from http to https usage), the wpv-post-featured-image shortcode will still be outputting HTTP links to your images.

We are basically getting the attachment’s URL using core functions, almost in all cases (in one specific case we rely on some data stored in the database directly). We are reviewing this and reporting a bug on get_the_post_thumbnail to see whether it should return SSL links when on front-end and is_ssl() is set to true.

Workaround

This issue needs to be addressed in the WordPress core itself. Until then, you can put the following snippet into your theme’s functions.php file and force the usage of HTTPS links for the image output of this shortcode.

add_filter( 'wpv-post-featured-image', 'replace_http_post_featured_image' );
function replace_http_post_featured_image( $out ){
    if( is_ssl() ){
        $out = str_replace("http", "https", $out);
    }

    return $out;
}

2 thought on Issue with the wpv-post-featured-image shortcode after moving site to SSL

  • This code breaks under the new Toolset Views. It should be:


    add_filter( 'wpv-post-featured-image', 'replace_http_post_featured_image' );
    function replace_http_post_featured_image( $out ){
    if( is_ssl() ){
    $out = str_replace("http:", "https:", $out);
    }

    return $out;
    }

    • Hi Mathew

      Thanks for your feedback. I do not fully follow how adding the colon can affect the outcome of this filter, unless your image does have the http string inside its title (which might be the case). Anyway, if you still experience any problem after applying the workaround please let us know on a support ticket and we will try our best to help you.

      Regards.

Comments are closed