You are here

protected function EntityUrlGeneratorBase::getEntityImageData in Simple XML sitemap 4.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGeneratorBase.php \Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityUrlGeneratorBase::getEntityImageData()

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity:

Return value

array

3 calls to EntityUrlGeneratorBase::getEntityImageData()
CustomUrlGenerator::processDataSet in src/Plugin/simple_sitemap/UrlGenerator/CustomUrlGenerator.php
@inheritdoc
EntityMenuLinkContentUrlGenerator::processDataSet in src/Plugin/simple_sitemap/UrlGenerator/EntityMenuLinkContentUrlGenerator.php
@inheritdoc
EntityUrlGenerator::processEntity in src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php

File

src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGeneratorBase.php, line 216

Class

EntityUrlGeneratorBase
Class EntityUrlGeneratorBase

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Code

protected function getEntityImageData(ContentEntityInterface $entity) : array {
  $image_data = [];
  foreach ($entity
    ->getFieldDefinitions() as $field) {
    if ($field
      ->getType() === 'image') {
      foreach ($entity
        ->get($field
        ->getName())
        ->getValue() as $value) {
        if (!empty($file = File::load($value['target_id']))) {
          $image_data[] = [
            'path' => $this
              ->replaceBaseUrlWithCustom(file_create_url($file
              ->getFileUri())),
            'alt' => $value['alt'],
            'title' => $value['title'],
          ];
        }
      }
    }
  }
  return $image_data;
}