I am looking to edit this part of the post template in Algolia autocomplete:
<# if ( data.images.thumbnail ) { #>
<img class="suggestion-post-thumbnail" src="{{ data.images.thumbnail.url }}" alt="{{ data.post_title }}">
<# } #>
Instead of the featured image attached to the post, I would like Algolia to get the 'medium' version of the featured image.
This is because, my featured images are very large and Algolia gets the full size for the small thumbnails shown on autocomplete.
All image thumbnail sizes are pushed to Algolia by default.
If the thumbnail size you are willing to display is medium, you can do:
<# if ( data.images.medium ) { #>
<img class="suggestion-post-thumbnail" src="{{ data.images.medium.url }}" alt="{{ data.post_title }}">
<# } #>
Note that if a new thumbnail size was introduced, you will need to re-index everything from the Indexing page of the plugin.
Update:
Since version 2.x of the plugin, we do not push all sizes by default to avoid huge record payloads.
As a replacement, we introduced a filter hook that allows you to specify the thumbnail sizes you want to push. i.e.
add_filter('algolia_post_images_sizes', function($sizes) {
$sizes[] = 'medium';
return $sizes;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With