Image size on Instantsearch page

Hello, I’m using the WordPress (4.7.5) plug-in from Algolia for our WooCommerce (3.0.8) based shop. It works nearly perfect, except one thing isn’t working anymore after upgrading to Algolia 2.3.0: I changed the image size on the instantsearch page (in the instantsearch.php template):

<# if ( data.images.medium ) { #>
    <img class="suggestion-post-thumbnail" src="{{ data.images.medium.url }}" alt="{{ data.post_title }}">
<# } #>

I changed the thumbnail sizes to the medium image size and re-indexed everything but the images aren’t displayed anymore.

Is it not possible anymore to change the image size?

Thanks for help,

1 Like

Hi there,

Since version 2.x of the plugin, we do not index all image sizes anymore because it resulted in heavy payloads containing lots of un-used thumbnail urls.

We also introduced a new filter hook to push custom sizes:

add_filter('algolia_post_images_sizes', function($sizes) {
    $sizes[] = 'medium'; 

    return $sizes;

After adding this hook you need to re-index all your data.
Let me know if that works!

1 Like

Hi Ray, thanks a lot for your quick reply.

I’ve added it in functions.php but the result is the same and it’s using the thumbnail size not the medium image size. Is there anything I forgot to do?

Is there a live example that we could see?
Can you correctly see the medium sized thumbnail urls in your index?

Sorry, it did work!!! There was a small typo in the hook I added.

Is it possible to change the image sizes in the Autocomplete search result too?

SOLVED! I figured it out. Works both on Autocomplete and Instantsearch results.

I love Algolia. Thanks a lot for your support!

1 Like

You are very welcome, feel free to ping us again in the future!

1 Like