It seems that the search result image, if available, is ignored and not added to the search result. This would be a nice feature to add.

This could be solved by adding the image src in the function
protected function prepareResults(array $items) { ... }
in Search.php and search for any instance of
$item->pagemap->cse_image[0]->src.

Not sure what the best solution is here but for now i have added the following row to the search results array
'image' => isset($item->pagemap->cse_image[0]->src) ? $item->pagemap->cse_image[0]->src : NULL,
to be able to control the markup and manually print the image in the search-result.html.twig
<img src="{{ result.img_src }}" alt="{{ title }}" />

Comments

Kleve created an issue. See original summary.

  • Deciphered committed 84acfc3 on 8.x-1.x
    #2833701: Added CSE thumbnails to search results.
    
deciphered’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Status: Active » Fixed

Went a different way, more inline with the standard Node search functionality, implementing a `hook_gss_search_result` hook that modules can implement and add data to the extras item on the search results, which is rendered by default in the `search-result.html.twig` template.

Themeability still exists.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.