Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 protected function buildDescription($entity) {
   $description = \Drupal::token()->replace($this->configuration['result_description'], ['term' => $entity], []);
   return LinkitXss::descriptionFilter($description);
 }
Beispiel #2
0
  /**
   * {@inheritdoc}
   */
  protected function buildDescription($entity) {
    $description_array = array();

    $description_array[] = parent::buildDescription($entity);

    /** @var \Drupal\file\FileInterface $entity */
    $file = $entity->getFileUri();

    /** @var \Drupal\Core\Image\ImageInterface $image */
    $image = \Drupal::service('image.factory')->get($file);
    if ($image->isValid()) {
      if ($this->configuration['images']['show_dimensions']) {
        $description_array[] = $image->getWidth() . 'x' . $image->getHeight() . 'px';
      }

      if ($this->configuration['images']['show_thumbnail'] && $this->moduleHandler->moduleExists('image')) {
        $image_element = array(
          '#weight' => -10,
          '#theme' => 'image_style',
          '#style_name' => $this->configuration['images']['thumbnail_image_style'],
          '#uri' => $entity->getFileUri(),
        );

        $description_array[] = (string) \Drupal::service('renderer')->render($image_element);
      }
    }

    $description = implode('<br />' , $description_array);
    return LinkitXss::descriptionFilter($description);
  }