public function generate($url, $width = null, $height = null, $options = null) {

        // Extract the path from a URL and remove it's leading slash
        $path = $this->toPath($url);

        // Skip croppa requests for images the ignore regexp
        if (isset($this->config['ignore'])
            && preg_match('#'.$this->config['ignore'].'#', $path)) {
            return $this->pathToUrl($path);
        }

        // Defaults
        if (empty($path)) return; // Don't allow empty strings
        if (!$width && !$height) return $this->pathToUrl($path); // Pass through if empty
        $width = $width ? round($width) : '_';
        $height = $height ? round($height) : '_';

        // Produce width, height, and options
        $suffix = '-'.$width.'x'.$height;
        if ($options && is_array($options)) {
            foreach($options as $key => $val) {
                if (is_numeric($key)) $suffix .= '-'.$val;
                elseif (is_array($val)) $suffix .= '-'.$key.'('.implode(',',$val).')';
                else $suffix .= '-'.$key.'('.$val.')';
            }
        }

        // Assemble the new path
        $parts = pathinfo($path);
        $path = trim($parts['dirname'],'/').'/'.$parts['filename'].$suffix;
        if (isset($parts['extension'])) $path .= '.'.$parts['extension'];
        $url = $this->pathToUrl($path);

        // Secure with hash token
        if ($token = $this->signingToken($url)) $url .= '?token='.$token;

        // Return the $url
        return $url;
    }
public function generate($url, $width = null, $height = null, $options = null) {

        // Extract the path from a URL and remove it's leading slash
        $path = $this->toPath($url);

        // Skip croppa requests for images the ignore regexp
        if (isset($this->config['ignore'])
            && preg_match('#'.$this->config['ignore'].'#', $path)) {
            return $this->pathToUrl($path);
        }

        // Defaults
        if (empty($path)) return; // Don't allow empty strings
        if (!$width && !$height) return $this->pathToUrl($path); // Pass through if empty
        $width = $width ? round($width) : '_';
        $height = $height ? round($height) : '_';

        // Produce width, height, and options
        $suffix = '-'.$width.'x'.$height;
        if ($options && is_array($options)) {
            foreach($options as $key => $val) {
                if (is_numeric($key)) $suffix .= '-'.$val;
                elseif (is_array($val)) $suffix .= '-'.$key.'('.implode(',',$val).')';
                else $suffix .= '-'.$key.'('.$val.')';
            }
        }

        // Assemble the new path
        $parts = pathinfo($path);
        $path = trim($parts['dirname'],'/').'/'.$parts['filename'].$suffix;
        if (isset($parts['extension'])) $path .= '.'.$parts['extension'];
        $url = $this->pathToUrl($path);

        // Secure with hash token
        if ($token = $this->signingToken($url)) $url .= '?token='.$token;

        // Return the $url
        return $url;
    }
public function generate ( $ url , $ width = null , $ height = null , $ options = null ) { // Extract the path from a URL and remove it's leading slash $ path = $ this -> toPath ( $ url ) ; // Skip croppa requests for images the ignore regexp if ( isset ( $ this -> config [ 'ignore' ] ) && preg_match ( '#' . $ this -> config [ 'ignore' ] . '#' , $ path ) ) { return $ this -> pathToUrl ( $ path ) ; } // Defaults if ( empty ( $ path ) ) return ; // Don't allow empty strings if ( ! $ width && ! $ height ) return $ this -> pathToUrl ( $ path ) ; // Pass through if empty $ width = $ width ? round ( $ width ) : '_' ; $ height = $ height ? round ( $ height ) : '_' ; // Produce width, height, and options $ suffix = '-' . $ width . 'x' . $ height ; if ( $ options && is_array ( $ options ) ) { foreach ( $ options as $ key => $ val ) { if ( is_numeric ( $ key ) ) $ suffix .= '-' . $ val ; elseif ( is_array ( $ val ) ) $ suffix .= '-' . $ key . '(' . implode ( ',' , $ val ) . ')' ; else $ suffix .= '-' . $ key . '(' . $ val . ')' ; } } // Assemble the new path $ parts = pathinfo ( $ path ) ; $ path = trim ( $ parts [ 'dirname' ] , '/' ) . '/' . $ parts [ 'filename' ] . $ suffix ; if ( isset ( $ parts [ 'extension' ] ) ) $ path .= '.' . $ parts [ 'extension' ] ; $ url = $ this -> pathToUrl ( $ path ) ; // Secure with hash token if ( $ token = $ this -> signingToken ( $ url ) ) $ url .= '?token=' . $ token ; // Return the $url return $ url ; }
Insert Croppa parameter suffixes into a URL.  For use as a helper in views
when rendering image src attributes.

@param string $url URL of an image that should be cropped
@param integer $width Target width
@param integer $height Target height
@param array $options Addtional Croppa options, passed as key/value pairs.  Like array('resize')
@return string The new path to your thumbnail
Insert Croppa parameter suffixes into a URL . For use as a helper in views when rendering image src attributes .