src/Utility/FileUpload.php
private function handleThumbnails(FileStorage $entity, string $eventName) : bool
    {
        if (! in_array(strtolower($entity->get('extension')), self::IMAGE_EXTENSIONS)) {
            return false;
        }

        $imgSizes = (array)Configure::read(sprintf('FileStorage.imageSizes.%s', $entity->get('model')));

        if (empty($imgSizes)) {
            $this->log(
                sprintf('Failed to %s: no image sizes defined for model "%s"', $eventName, $entity->get('model')),
                'warning'
            );

            return false;
        }

        $event = new Event($eventName, $this, [
            'entity' => $entity,
            'versions' => array_keys($imgSizes),
        ]);
        EventManager::instance()->dispatch($event);

        $eventResult = $event->getResult();
        if (empty($eventResult)) {
            $this->log(sprintf('Failed to %s: event result is empty', $eventName), 'error');

            return false;
        }

        $result = true;
        foreach (array_keys($imgSizes) as $version) {
            if (! array_key_exists($version, $eventResult)) {
                $result = false;
                $this->log(sprintf('Failed to %s for version "%s"', $eventName, $version), 'error');
            }

            if ('error' === $eventResult[$version]['status']) {
                $result = false;
                $this->log(sprintf('Failed to handle thumbnail: %s', $eventResult[$version]['error']), 'error');
            }
        }

        return $result;
    }
private function handleThumbnails(FileStorage $entity, string $eventName) : bool
    {
        if (! in_array(strtolower($entity->get('extension')), self::IMAGE_EXTENSIONS)) {
            return false;
        }

        $imgSizes = (array)Configure::read(sprintf('FileStorage.imageSizes.%s', $entity->get('model')));

        if (empty($imgSizes)) {
            $this->log(
                sprintf('Failed to %s: no image sizes defined for model "%s"', $eventName, $entity->get('model')),
                'warning'
            );

            return false;
        }

        $event = new Event($eventName, $this, [
            'entity' => $entity,
            'versions' => array_keys($imgSizes),
        ]);
        EventManager::instance()->dispatch($event);

        $eventResult = $event->getResult();
        if (empty($eventResult)) {
            $this->log(sprintf('Failed to %s: event result is empty', $eventName), 'error');

            return false;
        }

        $result = true;
        foreach (array_keys($imgSizes) as $version) {
            if (! array_key_exists($version, $eventResult)) {
                $result = false;
                $this->log(sprintf('Failed to %s for version "%s"', $eventName, $version), 'error');
            }

            if ('error' === $eventResult[$version]['status']) {
                $result = false;
                $this->log(sprintf('Failed to handle thumbnail: %s', $eventResult[$version]['error']), 'error');
            }
        }

        return $result;
    }
private function handleThumbnails ( FileStorage $ entity , string $ eventName ) : bool { if ( ! in_array ( strtolower ( $ entity -> get ( 'extension' ) ) , self :: IMAGE_EXTENSIONS ) ) { return false ; } $ imgSizes = ( array ) Configure :: read ( sprintf ( 'FileStorage.imageSizes.%s' , $ entity -> get ( 'model' ) ) ) ; if ( empty ( $ imgSizes ) ) { $ this -> log ( sprintf ( 'Failed to %s: no image sizes defined for model "%s"' , $ eventName , $ entity -> get ( 'model' ) ) , 'warning' ) ; return false ; } $ event = new Event ( $ eventName , $ this , [ 'entity' => $ entity , 'versions' => array_keys ( $ imgSizes ) , ] ) ; EventManager :: instance ( ) -> dispatch ( $ event ) ; $ eventResult = $ event -> getResult ( ) ; if ( empty ( $ eventResult ) ) { $ this -> log ( sprintf ( 'Failed to %s: event result is empty' , $ eventName ) , 'error' ) ; return false ; } $ result = true ; foreach ( array_keys ( $ imgSizes ) as $ version ) { if ( ! array_key_exists ( $ version , $ eventResult ) ) { $ result = false ; $ this -> log ( sprintf ( 'Failed to %s for version "%s"' , $ eventName , $ version ) , 'error' ) ; } if ( 'error' === $ eventResult [ $ version ] [ 'status' ] ) { $ result = false ; $ this -> log ( sprintf ( 'Failed to handle thumbnail: %s' , $ eventResult [ $ version ] [ 'error' ] ) , 'error' ) ; } } return $ result ; }
Method used for handling image file thumbnails creation and removal.

Note that the code on this method was borrowed fromBurzum/FileStorage
plugin, ImageVersionShell Class _loop method.

@param \Burzum\FileStorage\Model\Entity\FileStorage $entity FileStorage entity
@param string $eventName Event name
@return bool
Method used for handling image file thumbnails creation and removal .