You are here

private function FlickrFilter::callbackPhoto in Flickr 8

Filter callback for a photo.

File

modules/flickr_filter/src/Plugin/Filter/FlickrFilter.php, line 165

Class

FlickrFilter
Provides a filter to insert Flickr photo.

Namespace

Drupal\flickr_filter\Plugin\Filter

Code

private function callbackPhoto($matches) {
  list($config, $attribs) = $this->helpers
    ->splitConfig($matches[1]);
  if (isset($config['id'])) {
    if ($photo = $this->photos->flickrApiPhotos
      ->photosGetInfo($config['id'])) {
      if (!isset($config['size'])) {
        $config['size'] = $this->settings['flickr_filter_default_size'];
      }
      if (!isset($config['caption'])) {
        $config['caption'] = $this->settings['flickr_filter_caption'];
      }
      switch ($config['size']) {
        case "x":
        case "y":
          $this
            ->messenger()
            ->addError($this
            ->t("Do not use a slideshow for a single image."));
          $config['size'] = $this->settings['flickr_filter_default_size'];
          break;
      }
      $photoimg = $this->photos
        ->themePhoto($photo, $config['size'], $config['caption']);
      return render($photoimg);
    }
  }
  return '';
}