You are here

public function Photos::themePhoto in Flickr 8

Theme Photos.

Parameters

array $photo: Photo.

string $size: Size.

int $caption: Caption On Off.

string $parent: Parent.

Return value

array Return theme array.

1 call to Photos::themePhoto()
Photos::themePhotos in src/Service/Photos.php
Theme Photos.

File

src/Service/Photos.php, line 54

Class

Photos
Class Photos.

Namespace

Drupal\flickr\Service

Code

public function themePhoto(array $photo, $size, $caption = 0, $parent = NULL) {
  $photoSize = $this
    ->photoGetSize($photo['id'], $size);
  $photoSizeLarge = $this
    ->photoGetSize($photo['id'], 'b');
  if ($photoSize != FALSE) {
    $img = [
      '#theme' => 'image',
      '#style_name' => 'flickr-photo-' . $size . '-' . $photoSize['aspect'],
      '#uri' => $this->flickrApiHelpers
        ->photoImgUrl($photo, $size),
      '#alt' => $photo['title']['_content'] . ' by ' . $photo['owner']['realname'],
      '#title' => $photo['title']['_content'] . ' by ' . $photo['owner']['realname'],
      '#attributes' => [
        'width' => $photoSize['width'],
        'height' => $photoSize['height'],
      ],
    ];
    $photoimg = [
      '#theme' => 'flickr_photo',
      '#photo' => $img,
      '#caption' => $caption,
      '#photo_page_url' => $photo['urls']['url'][0]['_content'],
      '#photo_image_large' => $photoSizeLarge['source'],
      '#parent' => $parent,
      '#style_name' => 'flickr-photo-' . $size . '-' . $photoSize['aspect'],
      '#width' => $photoSize['width'],
      '#height' => $photoSize['height'],
      '#attached' => [
        'library' => [
          'flickr/flickr.stylez',
        ],
      ],
    ];
    if ($caption == 1) {
      $photoimg['#caption_data'] = $this
        ->themeCaption($photo, $size, $caption);
    }
    return $photoimg;
  }
}