protected function InstallHelper::processImage in Drupal 10
Same name and namespace in other branches
- 8 core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::processImage()
- 9 core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::processImage()
Process images into media entities.
Parameters
array $data: Data of line that was read from the file.
Return value
array Data structured as a image.
File
- core/
profiles/ demo_umami/ modules/ demo_umami_content/ src/ InstallHelper.php, line 355
Class
- InstallHelper
- Defines a helper class for importing default content.
Namespace
Drupal\demo_umami_contentCode
protected function processImage(array $data) {
// Set article author.
if (!empty($data['author'])) {
$values['uid'] = $this
->getUser($data['author']);
}
$image_path = $this->module_path . '/default_content/images/' . $data['image'];
// Prepare content.
$values = [
'name' => $data['title'],
'bundle' => 'image',
'langcode' => 'en',
'field_media_image' => [
'target_id' => $this
->createFileEntity($image_path),
'alt' => $data['alt'],
],
];
return $values;
}