public function image(Environment $env, $fileName = null, $width = null, $height = null, $crop = null)
    {
        //Check if it's an alias as the only parameter after $filename
        if ($width && !$height && !$crop && $this->isAlias($width)) {
            return $this->getAliasedUri($fileName, $width);
        }

        if ($width || $height) {
            // You don't want the image, you just want a thumbnail.
            return $this->thumbnail($fileName, $width, $height, $crop);
        }

        // After v1.5.1 we store image data as an array
        $fileName = $this->normalizeFileName($fileName);

        // If _no_ filename is given, return nothing.
        if (!$fileName) {
            return null;
        }

        try {
            $file = $this->filesystemMatcher->getFile($fileName);
            $url = $file->url();
        } catch (FileNotFoundException $e) {
            // If a non-existing filename is given, we either re-throw the Exception (in DEV) or defer to the
            // Thumbnailer, so the user sees the "404 image".
            if ($env->isDebug()) {
                throw $e;
            }
            $url = $this->getThumbnailUri($this->getThumbnail($fileName));
        }

        return $url;
    }
public function image(Environment $env, $fileName = null, $width = null, $height = null, $crop = null)
    {
        //Check if it's an alias as the only parameter after $filename
        if ($width && !$height && !$crop && $this->isAlias($width)) {
            return $this->getAliasedUri($fileName, $width);
        }

        if ($width || $height) {
            // You don't want the image, you just want a thumbnail.
            return $this->thumbnail($fileName, $width, $height, $crop);
        }

        // After v1.5.1 we store image data as an array
        $fileName = $this->normalizeFileName($fileName);

        // If _no_ filename is given, return nothing.
        if (!$fileName) {
            return null;
        }

        try {
            $file = $this->filesystemMatcher->getFile($fileName);
            $url = $file->url();
        } catch (FileNotFoundException $e) {
            // If a non-existing filename is given, we either re-throw the Exception (in DEV) or defer to the
            // Thumbnailer, so the user sees the "404 image".
            if ($env->isDebug()) {
                throw $e;
            }
            $url = $this->getThumbnailUri($this->getThumbnail($fileName));
        }

        return $url;
    }
public function image ( Environment $ env , $ fileName = null , $ width = null , $ height = null , $ crop = null ) { //Check if it's an alias as the only parameter after $filename if ( $ width && ! $ height && ! $ crop && $ this -> isAlias ( $ width ) ) { return $ this -> getAliasedUri ( $ fileName , $ width ) ; } if ( $ width || $ height ) { // You don't want the image, you just want a thumbnail. return $ this -> thumbnail ( $ fileName , $ width , $ height , $ crop ) ; } // After v1.5.1 we store image data as an array $ fileName = $ this -> normalizeFileName ( $ fileName ) ; // If _no_ filename is given, return nothing. if ( ! $ fileName ) { return null ; } try { $ file = $ this -> filesystemMatcher -> getFile ( $ fileName ) ; $ url = $ file -> url ( ) ; } catch ( FileNotFoundException $ e ) { // If a non-existing filename is given, we either re-throw the Exception (in DEV) or defer to the // Thumbnailer, so the user sees the "404 image". if ( $ env -> isDebug ( ) ) { throw $ e ; } $ url = $ this -> getThumbnailUri ( $ this -> getThumbnail ( $ fileName ) ) ; } return $ url ; }
Helper function to make a path to an image.

@param Environment  $env
@param string|array $fileName Target filename
@param string|int   $width    Target width
@param string|int   $height   Target height
@param string       $crop     String identifier for cropped images

@return string Image path
Helper function to make a path to an image .