protected function BatchWatermarkForm::prepareImages in Media watermark 8
Helper to prepare images.
Parameters
\Drupal\media_watermark\Entity\MediaWatermarkInterface[] $watermarks: List of Media Watermark entities.
Return value
array Renderable array.
1 call to BatchWatermarkForm::prepareImages()
- BatchWatermarkForm::buildForm in src/
Form/ BatchWatermarkForm.php - Define the form used for ContentEntityExample settings.
File
- src/
Form/ BatchWatermarkForm.php, line 438
Class
- BatchWatermarkForm
- Class BatchWatermarkForm.
Namespace
Drupal\media_watermark\FormCode
protected function prepareImages(array $watermarks) {
$output = [];
// Build render array.
$output['images'] = [
'#type' => 'container',
'#prefix' => '<div id="edit-watermarks-images">',
'#suffix' => '</div>',
'#weight' => 18,
];
foreach ($watermarks as $watermark) {
$fids = $watermark
->getFid();
if (!empty($fids)) {
$fid = reset($fids);
$file = File::load($fid);
if (is_object($file)) {
$output['images']['image-' . $fid] = [
'#theme' => 'image_style',
'#width' => 200,
'#height' => NULL,
'#style_name' => 'media_watermark',
'#uri' => $file
->getFileUri(),
'#prefix' => '<div class="image-hidden" id="image-' . $fid . '">',
'#suffix' => '</div>',
];
}
}
}
return $output;
}