public function render()
{
$files = $this->getFiles();
$images = $this->preprocessImages($files, true);
if (true === empty($images)) {
return null;
}
$info = [];
$tags = [];
foreach ($images as &$image) {
$source = $this->preprocessSourceUri($image['source']);
$width = $image['info'][0];
$height = $image['info'][1];
$alt = $this->arguments['alt'];
if (true === empty($alt)) {
$alt = $image['file']['alternative'];
}
$this->tag->addAttribute('src', $source);
$this->tag->addAttribute('width', $width);
$this->tag->addAttribute('height', $height);
$this->tag->addAttribute('alt', $alt);
$tag = $this->tag->render();
$image['tag'] = $tag;
$tags[] = $tag;
$info[] = ['source' => $source, 'width' => $width, 'height' => $height, 'tag' => $tag];
}
$as = $this->arguments['as'];
if (true === empty($as)) {
return implode('', $tags);
}
return $this->renderChildrenWithVariableOrReturnInput($info);
}