function InstallHelper::processImage
Same name in other branches
- 9 core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::processImage()
- 8.9.x core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::processImage()
- 11.x 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.
1 call to InstallHelper::processImage()
- InstallHelper::processContent in core/
profiles/ demo_umami/ modules/ demo_umami_content/ src/ InstallHelper.php - Process content into a structure that can be saved into Drupal.
File
-
core/
profiles/ demo_umami/ modules/ demo_umami_content/ src/ InstallHelper.php, line 381
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.