public function showImage($fileName = null, $width = null, $height = null, $crop = null)
    {
        if (empty($fileName)) {
            return '';
        }
        $thumb = $this->getThumbnail($fileName, $width, $height, $crop);

        if ($width === null && $height === null) {
            $thumbconf = $this->config->get('general/thumbnails');
            $width = !empty($thumbconf['default_image'][0]) ? $thumbconf['default_image'][0] : 1000;
            $height = !empty($thumbconf['default_image'][1]) ? $thumbconf['default_image'][1] : 750;
            $thumb->setWidth($width);
            $thumb->setHeight($height);
        } elseif ($width === null xor $height === null) {
            $info = $this->imageInfo($thumb->getFileName())->getInfo();

            if ($width !== null) {
                $width = min($width, $info->getWidth());
                $thumb->setHeight(round($width / $info->getAspectRatio()));
            } elseif ($height !== null) {
                $height = min($height, $info->getHeight());
                $thumb->setWidth(round($height * $info->getAspectRatio()));
            } else {
                $thumb->setWidth($info->getWidth());
                $thumb->setHeight($info->getHeight());
            }
        }

        return sprintf(
            '<img src="%s" width="%s" height="%s" alt="%s">',
            $this->getThumbnailUri($thumb),
            $thumb->getWidth(),
            $thumb->getHeight(),
            $thumb->getAltTitle()
        );
    }
public function showImage($fileName = null, $width = null, $height = null, $crop = null)
    {
        if (empty($fileName)) {
            return '';
        }
        $thumb = $this->getThumbnail($fileName, $width, $height, $crop);

        if ($width === null && $height === null) {
            $thumbconf = $this->config->get('general/thumbnails');
            $width = !empty($thumbconf['default_image'][0]) ? $thumbconf['default_image'][0] : 1000;
            $height = !empty($thumbconf['default_image'][1]) ? $thumbconf['default_image'][1] : 750;
            $thumb->setWidth($width);
            $thumb->setHeight($height);
        } elseif ($width === null xor $height === null) {
            $info = $this->imageInfo($thumb->getFileName())->getInfo();

            if ($width !== null) {
                $width = min($width, $info->getWidth());
                $thumb->setHeight(round($width / $info->getAspectRatio()));
            } elseif ($height !== null) {
                $height = min($height, $info->getHeight());
                $thumb->setWidth(round($height * $info->getAspectRatio()));
            } else {
                $thumb->setWidth($info->getWidth());
                $thumb->setHeight($info->getHeight());
            }
        }

        return sprintf(
            '<img src="%s" width="%s" height="%s" alt="%s">',
            $this->getThumbnailUri($thumb),
            $thumb->getWidth(),
            $thumb->getHeight(),
            $thumb->getAltTitle()
        );
    }
public function showImage ( $ fileName = null , $ width = null , $ height = null , $ crop = null ) { if ( empty ( $ fileName ) ) { return '' ; } $ thumb = $ this -> getThumbnail ( $ fileName , $ width , $ height , $ crop ) ; if ( $ width === null && $ height === null ) { $ thumbconf = $ this -> config -> get ( 'general/thumbnails' ) ; $ width = ! empty ( $ thumbconf [ 'default_image' ] [ 0 ] ) ? $ thumbconf [ 'default_image' ] [ 0 ] : 1000 ; $ height = ! empty ( $ thumbconf [ 'default_image' ] [ 1 ] ) ? $ thumbconf [ 'default_image' ] [ 1 ] : 750 ; $ thumb -> setWidth ( $ width ) ; $ thumb -> setHeight ( $ height ) ; } elseif ( $ width === null xor $ height === null ) { $ info = $ this -> imageInfo ( $ thumb -> getFileName ( ) ) -> getInfo ( ) ; if ( $ width !== null ) { $ width = min ( $ width , $ info -> getWidth ( ) ) ; $ thumb -> setHeight ( round ( $ width / $ info -> getAspectRatio ( ) ) ) ; } elseif ( $ height !== null ) { $ height = min ( $ height , $ info -> getHeight ( ) ) ; $ thumb -> setWidth ( round ( $ height * $ info -> getAspectRatio ( ) ) ) ; } else { $ thumb -> setWidth ( $ info -> getWidth ( ) ) ; $ thumb -> setHeight ( $ info -> getHeight ( ) ) ; } } return sprintf ( '<img src="%s" width="%s" height="%s" alt="%s">' , $ this -> getThumbnailUri ( $ thumb ) , $ thumb -> getWidth ( ) , $ thumb -> getHeight ( ) , $ thumb -> getAltTitle ( ) ) ; }
Helper function to show an image on a rendered page.

Set width or height parameter to '0' for proportional scaling.
Set them both to null (or not at all) to get the default size from config.yml.

Example: {{ content.image|showimage(320, 240) }}
Example: {{ showimage(content.image, 320, 240) }}

@param string $fileName Image filename
@param int    $width    Image width
@param int    $height   Image height
@param string $crop     Crop image string identifier

@return string HTML output
Helper function to show an image on a rendered page .