Back to SiteSearch Support

Dione
Dione

Hi there

My content thumbnail is not appearing in search result for some reason, it doesn't return any error, it only displays the image not loaded icon instead of the thumbnail in frontend, i can give you any information you need to help me identify the problem and i will be truly greatful if you do so

Plugin.php:

\Event::listen('offline.sitesearch.query', function ($query){
  $items = Models\Category::where('category_title', 'like', "%${query}%")
  ->get();

  $results = $items->map(function ($item) use ($query){
    $relevance = mb_stripos($item->title, $query) !== false ? 2 : 1;

    return [
      'title'     => $item->category_title,
      'url'       => 'categories/' . $item->slug,
      'thumb'     => optional($item->categoryimage)->first(),
      'relevance' => $relevance
    ];
  });

  return [
    'provider' => 'category',
    'results'  => $results,
  ];
});

Models/Category.php

public $attachOne = [
  'categoryimage' => 'System\Models\File'
];
OFFLINE
OFFLINE

This should not be a problem with this plugin. The plugin only gathers your search results and then returns the model to you. Generating the image is the job of the CMS itself. The image is generated here: https://github.com/OFFLINE-GmbH/oc-site-search-plugin/blob/develop/components/searchresults/thumbnail.htm#L3

If you don't see your thumbnail, check from where it tries to fetch it. Maybe your app.url config setting is wrong or the image folder is not accessible via your browser.

Dione
Dione

OFFLINE said:

This should not be a problem with this plugin. The plugin only gathers your search results and then returns the model to you. Generating the image is the job of the CMS itself. The image is generated here: https://github.com/OFFLINE-GmbH/oc-site-search-plugin/blob/develop/components/searchresults/thumbnail.htm#L3

If you don't see your thumbnail, check from where it tries to fetch it. Maybe your app.url config setting is wrong or the image folder is not accessible via your browser.

Thank you for your response

i stripped {{ result.thumb.path }} from the img tag and it shows the video url instead of thumbnail for some reason, i couldn't find a solution so i kept the video as a thumbnail...

now i have another problem, all search results have the same thumb (same video url in my case), is this problem related to SiteSearch plugin?

Dione
Dione

It turns out calling first() is the source of trouble, this is the fix for both issues: https://github.com/OFFLINE-GmbH/oc-site-search-plugin/issues/39#issuecomment-303704295

1-4 of 4