public function addItemAt($position, $name, $parameters, $media = null)
{
if (!$media || $media == "default") {
$itemContainer =& $this->items;
} else {
$this->createMediaIfNotExists($media);
$itemContainer =& $this->medias[$media];
}
array_splice($itemContainer, $position, 0, [["method" => $name, "arguments" => $parameters]]);
return true;
}
/** * @param null $thumbnailName * @return mixed */ public function getThumbnail($thumbnailName = null) { if (!$this->getImage()) { return ""; } $crop = null; if (is_array($this->getCrop())) { $crop = $this->getCrop(); } $thumbConfig = $this->getImage()->getThumbnailConfig($thumbnailName); if (!$thumbConfig && $crop) { $thumbConfig = new Asset\Image\Thumbnail\Config(); } if ($crop) { $thumbConfig->addItemAt(0, "cropPercent", array("width" => $crop["cropWidth"], "height" => $crop["cropHeight"], "y" => $crop["cropTop"], "x" => $crop["cropLeft"])); $hash = md5(\Pimcore\Tool\Serialize::serialize($thumbConfig->getItems())); $thumbConfig->setName($thumbConfig->getName() . "_auto_" . $hash); } return $this->getImage()->getThumbnail($thumbConfig); }