Pimcore\Model\Asset\Image\Thumbnail\Config::addItemAt PHP Method

addItemAt() public method

public addItemAt ( $position, $name, $parameters, $media = null ) : boolean
$name
$parameters
return boolean
    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;
    }

Usage Example

Example #1
0
 /**
  * @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);
 }
All Usage Examples Of Pimcore\Model\Asset\Image\Thumbnail\Config::addItemAt