type == 'image' && $document->entity == 'node') {
$areas = array();
// A problem here - small images do not get a derived thumbnail.
$sizes = image_get_derivative_sizes($node->images['_original']);
foreach ($sizes as $name => $info) {
$areas[$name] = $info['width'] * $info['height'];
}
asort($areas);
$image_path = FALSE;
foreach ($areas as $preset => $size) {
$image_path = $node->images[$preset];
break;
}
if ($image_path) {
$document->ss_image_relative = $image_path;
// Support multi-site too.
$document->ss_image_absolute = file_create_url($image_path);
}
}
}
/**
* Implementation of hook_apachesolr_modify_query().
*/
function apachesolr_image_apachesolr_modify_query(&$query, &$params, $caller) {
// Also retrieve image thumbnail links.
$params['fl'] .= ',ss_image_relative';
}
/**
* Implementation of hook_apachesolr_process_results().
*/
function apachesolr_image_apachesolr_process_results(&$results) {
foreach ($results as $index => $item) {
if ($item['node']->type == 'image' && !empty($item['node']->ss_image_relative)) {
$results[$index]['snippet'] = theme('apachesolr_image_snippet', $item);
}
}
}
function theme_apachesolr_image_snippet($item) {
return '' . theme('image', $item['node']->ss_image_relative, $item['title'], $item['title'], array('align' => 'left')) . '' . $item['snippet'] . '
';
}
/**
* Implementation of hook_enable().
*/
function apachesolr_image_enable() {
drupal_set_message(t('The Apache Solr image integration module will not have any apparent effect until Image type nodes are indexed or re-indexed.'));
}