You are here

protected function DemoContent::prepareImage in Open Social 8.6

Same name and namespace in other branches
  1. 8.9 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  2. 8.2 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  3. 8.3 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  4. 8.4 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  5. 8.5 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  6. 8.7 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  7. 8.8 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  8. 10.3.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  9. 10.0.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  10. 10.1.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()
  11. 10.2.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::prepareImage()

Prepares data about an image.

Parameters

string $picture: The image uuid.

string $alt: The image alt text.

Return value

array Returns an array for the image field.

7 calls to DemoContent::prepareImage()
Book::getEntry in modules/custom/social_demo/src/Plugin/DemoContent/Book.php
Makes an array with data of an entity.
DemoGroup::createContent in modules/custom/social_demo/src/DemoGroup.php
Creates content.
DemoSystem::replaceAnBlock in modules/custom/social_demo/src/DemoSystem.php
Function to replace the AN homepage Block.
DemoUser::createContent in modules/custom/social_demo/src/DemoUser.php
Creates content.
Event::getEntry in modules/custom/social_demo/src/Plugin/DemoContent/Event.php
Makes an array with data of an entity.

... See full list

File

modules/custom/social_demo/src/DemoContent.php, line 256

Class

DemoContent
Class DemoContent.

Namespace

Drupal\social_demo

Code

protected function prepareImage($picture, $alt = '') {
  $value = NULL;
  $files = $this
    ->loadByUuid('file', $picture);
  if ($files instanceof File) {
    $value = [
      [
        'target_id' => $files
          ->id(),
        'alt' => $alt ?: 'file' . $files
          ->id(),
      ],
    ];
  }
  return $value;
}