• Resolved bashy

    (@bashy)


    Hi there, thanks for the great plug-in.
    How to add the thumbnail of the featured image at the top of the info window above the store name.
    Thanks in advance for your response.

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey there, thanks for reaching out.

    Yes, showing the featured image in the info window is definitely possible.

    First you need to include the thumbnail url in the metadata that is sent to the frontend thanks to the wpsl_store_meta filter. Just add this code snippet in your active theme’s functions.php file, so the thumbnail URL is available in the templates:

    add_filter( 'wpsl_store_meta', 'custom_store_meta', 10, 2 );
    
    function custom_store_meta( $store_meta, $store_id ) {
        $url = wp_get_attachment_url( get_post_thumbnail_id( $store_id) );
        $store_meta['post_thumbnail_url'] = $url;
        return $store_meta;
    }

    And secondly, you also need to add a small code snippet in the wpsl_info_window_template to insert this newly created variable in the info window template, wherever you want to have it displayed:

    $info_window_template .= "\t\t\t" . '<% if ( post_thumbnail_url ) { %>' . "\r\n";
    $info_window_template .= "\t\t\t" . '<img src="<%= post_thumbnail_url %>"/>' . "\r\n";
    $info_window_template .= "\t\t\t" . '<% } %>' . "\r\n";

    I hope that helps. But get back if you get stuck somewhere.

    Regards,

    Thread Starter bashy

    (@bashy)

    [resolved]

    Hi there,
    It works like a charm! Thanks for your support and for your fast response.
    You definitely deserve 5 star rating.

    Regards,

    Hey there, massive thanks for the review! It really matters a lot to us!

    All the best,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Featured image at the top of the info window’ is closed to new replies.