You are here

function LinkitSearchPluginFile::createDescription in Linkit 7.3

Overrides LinkitSearchPluginEntity::createDescription().

If the file is an image, a small thumbnail can be added to the description. Also, image dimensions can be shown.

Overrides LinkitSearchPluginEntity::createDescription

File

plugins/linkit_search/file.class.php, line 47
Define Linkit file search plugin class.

Class

LinkitSearchPluginFile
Reprecents a Linkit file search plugin.

Code

function createDescription($data) {
  $description_array = array();

  // Get image info.
  $imageinfo = image_get_info($data->uri);

  // Add small thumbnail to the description.
  if ($this->conf['image_extra_info']['thumbnail']) {
    $image = $imageinfo ? theme_image_style(array(
      'width' => $imageinfo['width'],
      'height' => $imageinfo['height'],
      'style_name' => 'linkit_thumb',
      'path' => $data->uri,
    )) : '';
  }

  // Add image dimensions to the description.
  if ($this->conf['image_extra_info']['dimensions'] && !empty($imageinfo)) {
    $description_array[] = $imageinfo['width'] . 'x' . $imageinfo['height'] . 'px';
  }
  $description_array[] = parent::createDescription($data);

  // Add tiel files scheme to the description.
  if ($this->conf['show_scheme']) {
    $description_array[] = file_uri_scheme($data->uri) . '://';
  }
  $description = (isset($image) ? $image : '') . implode('<br />', $description_array);
  return $description;
}