src/Service/Cdn.php
public function urlCrop($iObjectId, $iWidth, $iHeight)
    {
        if (!$this->isPermittedDimension($iWidth, $iHeight)) {
            throw new PermittedDimensionException(
                'CDN::urlCrop() - Transformation of image to ' . $iWidth . 'x' . $iHeight . ' is not permitted'
            );
        }

        // --------------------------------------------------------------------------

        $isTrashed = false;

        if (empty($iObjectId)) {
            $oObj = $this->emptyObject();
        } elseif (is_numeric($iObjectId)) {

            $oObj = $this->getObject($iObjectId);

            if (!$oObj) {

                /**
                 * If the user is a logged in admin with can_browse_trash permission then have a look in the trash
                 */

                if (userHasPermission('admin:cdn:trash:browse')) {

                    $oObj = $this->getObjectFromTrash($iObjectId);

                    if (!$oObj) {
                        //  Cool, guess it really doesn't exist. Let the renderer show a bad_src graphic
                        $oObj = $this->emptyObject();
                    } else {
                        $isTrashed = true;
                    }
                } else {
                    //  Let the renderer show a bad_src graphic
                    $oObj = $this->emptyObject();
                }
            }
        } else {
            $oObj = $iObjectId;
        }

        // --------------------------------------------------------------------------

        $sCacheUrl = static::getCacheUrl(
            $oObj->bucket->slug,
            $oObj->file->name->disk,
            $oObj->file->ext,
            'CROP',
            $oObj->img_orientation,
            $iWidth,
            $iHeight
        );

        if (!empty($sCacheUrl)) {
            return $sCacheUrl;
        }

        // --------------------------------------------------------------------------

        $sUrl = $this->callDriver(
            'urlCrop',
            [$oObj->file->name->disk, $oObj->bucket->slug, $iWidth, $iHeight],
            $oObj->driver
        );
        $sUrl .= $isTrashed ? '?trashed=1' : '';

        return $sUrl;
    }
public function urlCrop($iObjectId, $iWidth, $iHeight)
    {
        if (!$this->isPermittedDimension($iWidth, $iHeight)) {
            throw new PermittedDimensionException(
                'CDN::urlCrop() - Transformation of image to ' . $iWidth . 'x' . $iHeight . ' is not permitted'
            );
        }

        // --------------------------------------------------------------------------

        $isTrashed = false;

        if (empty($iObjectId)) {
            $oObj = $this->emptyObject();
        } elseif (is_numeric($iObjectId)) {

            $oObj = $this->getObject($iObjectId);

            if (!$oObj) {

                /**
                 * If the user is a logged in admin with can_browse_trash permission then have a look in the trash
                 */

                if (userHasPermission('admin:cdn:trash:browse')) {

                    $oObj = $this->getObjectFromTrash($iObjectId);

                    if (!$oObj) {
                        //  Cool, guess it really doesn't exist. Let the renderer show a bad_src graphic
                        $oObj = $this->emptyObject();
                    } else {
                        $isTrashed = true;
                    }
                } else {
                    //  Let the renderer show a bad_src graphic
                    $oObj = $this->emptyObject();
                }
            }
        } else {
            $oObj = $iObjectId;
        }

        // --------------------------------------------------------------------------

        $sCacheUrl = static::getCacheUrl(
            $oObj->bucket->slug,
            $oObj->file->name->disk,
            $oObj->file->ext,
            'CROP',
            $oObj->img_orientation,
            $iWidth,
            $iHeight
        );

        if (!empty($sCacheUrl)) {
            return $sCacheUrl;
        }

        // --------------------------------------------------------------------------

        $sUrl = $this->callDriver(
            'urlCrop',
            [$oObj->file->name->disk, $oObj->bucket->slug, $iWidth, $iHeight],
            $oObj->driver
        );
        $sUrl .= $isTrashed ? '?trashed=1' : '';

        return $sUrl;
    }
public function urlCrop ( $ iObjectId , $ iWidth , $ iHeight ) { if ( ! $ this -> isPermittedDimension ( $ iWidth , $ iHeight ) ) { throw new PermittedDimensionException ( 'CDN::urlCrop() - Transformation of image to ' . $ iWidth . 'x' . $ iHeight . ' is not permitted' ) ; } // -------------------------------------------------------------------------- $ isTrashed = false ; if ( empty ( $ iObjectId ) ) { $ oObj = $ this -> emptyObject ( ) ; } elseif ( is_numeric ( $ iObjectId ) ) { $ oObj = $ this -> getObject ( $ iObjectId ) ; if ( ! $ oObj ) { /**
                 * If the user is a logged in admin with can_browse_trash permission then have a look in the trash
                 */ if ( userHasPermission ( 'admin:cdn:trash:browse' ) ) { $ oObj = $ this -> getObjectFromTrash ( $ iObjectId ) ; if ( ! $ oObj ) { //  Cool, guess it really doesn't exist. Let the renderer show a bad_src graphic $ oObj = $ this -> emptyObject ( ) ; } else { $ isTrashed = true ; } } else { //  Let the renderer show a bad_src graphic $ oObj = $ this -> emptyObject ( ) ; } } } else { $ oObj = $ iObjectId ; } // -------------------------------------------------------------------------- $ sCacheUrl = static :: getCacheUrl ( $ oObj -> bucket -> slug , $ oObj -> file -> name -> disk , $ oObj -> file -> ext , 'CROP' , $ oObj -> img_orientation , $ iWidth , $ iHeight ) ; if ( ! empty ( $ sCacheUrl ) ) { return $ sCacheUrl ; } // -------------------------------------------------------------------------- $ sUrl = $ this -> callDriver ( 'urlCrop' , [ $ oObj -> file -> name -> disk , $ oObj -> bucket -> slug , $ iWidth , $ iHeight ] , $ oObj -> driver ) ; $ sUrl .= $ isTrashed ? '?trashed=1' : '' ; return $ sUrl ; }
Calls the driver's public urlCrop method

@param int $iObjectId The ID of the object we're cropping
@param int $iWidth    The width of the crop
@param int $iHeight   The height of the crop

@return  string
Calls the driver s public urlCrop method