Wordpress Plugin only indexing 150x150 Image

Hello I wanted algolia to index the featured image of the posts. Right now it only indexes 150 by 150 version which is very small.

Can it be done?

Hi @harshmaur,

Since version 2.x of the plugin, we only index 1 image format by default.
You can push additional sizes by following the examples here: https://community.algolia.com/wordpress/frequently-asked-questions.html#can-i-use-custom-thumbnail-sizes-

Let me know if that helps,

Cheers!

Hey, Thanks for the reply. I am not able to understand properly on how to do it? Can you please mention what files I have to edit make it work?

Little knowledge on wordpress. :sweat:

Sure,

  1. Go to the folder in which resides your active theme (/wp-content/themes/my-theme)
  2. open the "functions.php"file
  3. copy paste the code snippet here at the end of the file:
add_filter('algolia_post_images_sizes', function($sizes) {
    $sizes[] = 'medium';

    return $sizes;
});
  1. re-index your posts by hitting the “re-index” button

Does that work?

Is it possible to index a custom size?

Yes, if I remember correctly, instead of returning “medium” in my example, you can return an array containing the width and height:

add_filter('algolia_post_images_sizes', function($sizes) {
    $sizes[] = array(250, 300);

    return $sizes;
});

If that doesn’t work, you would need to first register a custom image size, and use the name of the new format, see: https://developer.wordpress.org/reference/functions/add_image_size/

I hope that helps :wink:

For users of the WooCommerce Beta plugin, here is the necessary fix:

  1. Go to the folder in which resides your active theme (/wp-content/themes/my-theme)
  2. open the "functions.php"file
  3. copy paste the code snippet here at the end of the file:
add_filter('algolia_post_images_sizes', function($sizes) {
    $sizes[] = 'shop_catalog';

    return $sizes;
});
  1. re-index your posts by hitting the “re-index” button

Hi,
I’ve implemented the above mentioned code in my functions.php and then reindexed everything.
But the custom image size doesn’t work?

(I’m running version 2.6.1)