Display thumbnail in search result

WE HAVE MOVED!

Please visit our new Drupal Website at https://www.xenyo.com我們的新網頁設計公司網頁.

function modulename_preprocess_search_result(&$variables) {
  switch($variables['result']['node']->type) {
    case 'nodetype1':
      $n = node_load($variables['result']['node']->nid);
      $n && ($variables['node'] = $n);
      break;
  default:
  break;
}
 
 
search-result.tpl.php
<?php if ($variables['result']['node']->type == 'nodetype1' && isset($variables['result']['node']->field_image[LANGUAGE_NONE][0]['uri'])): ?>
<?php
$image = theme('image_style', array('style_name' => 'thumbnail', 'path' => $variables['result']['node']->field_image[LANGUAGE_NONE][0]['uri']));
?>
Help Share this Article