public function display($content, $options = [])
    {
        $imageData = $this->_defaultData($content);

        if (empty($imageData->file)) {
            return '';
        }

        if (empty($imageData->title)) {
            if (empty($options['title'])) {
                $fileName = substr(strrchr($imageData->file, '/'), 1);
                $imageData->title = str_replace('_', ' ', preg_replace('/\\.[^.\\s]{3,4}$/', '', $fileName));
            } else {
                $imageData->title = $options['title'];
            }
        }

        $imageData->extra_attrs = '';
        $ignoreAttributes = ['height', 'width', 'group', 'view', 'title', 'croppaOptions', 'version'];
        foreach ($options as $option => $val) {
            if (!in_array($option, $ignoreAttributes)) {
                $imageData->extra_attrs .= $option . '="' . $val . '" ';
            }
        }

        $imageData->group = !empty($options['group']) ? $options['group'] : '';
        $imageData->original = URL::to($imageData->file);

        $height = !empty($options['height']) ? $options['height'] : null;
        $width = !empty($options['width']) ? $options['width'] : null;
        if ($height || $width) {
            $croppaOptions = !empty($options['croppaOptions']) ? $options['croppaOptions'] : [];
            $imageData->file = str_replace(URL::to('/'), '', $imageData->file);
            $imageData->file = \Croppa::url($imageData->file, $width, $height, $croppaOptions);
        } else {
            $imageData->file = $imageData->original;
        }
        return $this->_renderDisplayView($options, $imageData);
    }
public function display($content, $options = [])
    {
        $imageData = $this->_defaultData($content);

        if (empty($imageData->file)) {
            return '';
        }

        if (empty($imageData->title)) {
            if (empty($options['title'])) {
                $fileName = substr(strrchr($imageData->file, '/'), 1);
                $imageData->title = str_replace('_', ' ', preg_replace('/\\.[^.\\s]{3,4}$/', '', $fileName));
            } else {
                $imageData->title = $options['title'];
            }
        }

        $imageData->extra_attrs = '';
        $ignoreAttributes = ['height', 'width', 'group', 'view', 'title', 'croppaOptions', 'version'];
        foreach ($options as $option => $val) {
            if (!in_array($option, $ignoreAttributes)) {
                $imageData->extra_attrs .= $option . '="' . $val . '" ';
            }
        }

        $imageData->group = !empty($options['group']) ? $options['group'] : '';
        $imageData->original = URL::to($imageData->file);

        $height = !empty($options['height']) ? $options['height'] : null;
        $width = !empty($options['width']) ? $options['width'] : null;
        if ($height || $width) {
            $croppaOptions = !empty($options['croppaOptions']) ? $options['croppaOptions'] : [];
            $imageData->file = str_replace(URL::to('/'), '', $imageData->file);
            $imageData->file = \Croppa::url($imageData->file, $width, $height, $croppaOptions);
        } else {
            $imageData->file = $imageData->original;
        }
        return $this->_renderDisplayView($options, $imageData);
    }
public function display ( $ content , $ options = [ ] ) { $ imageData = $ this -> _defaultData ( $ content ) ; if ( empty ( $ imageData -> file ) ) { return '' ; } if ( empty ( $ imageData -> title ) ) { if ( empty ( $ options [ 'title' ] ) ) { $ fileName = substr ( strrchr ( $ imageData -> file , '/' ) , 1 ) ; $ imageData -> title = str_replace ( '_' , ' ' , preg_replace ( '/\\.[^.\\s]{3,4}$/' , '' , $ fileName ) ) ; } else { $ imageData -> title = $ options [ 'title' ] ; } } $ imageData -> extra_attrs = '' ; $ ignoreAttributes = [ 'height' , 'width' , 'group' , 'view' , 'title' , 'croppaOptions' , 'version' ] ; foreach ( $ options as $ option => $ val ) { if ( ! in_array ( $ option , $ ignoreAttributes ) ) { $ imageData -> extra_attrs .= $ option . '="' . $ val . '" ' ; } } $ imageData -> group = ! empty ( $ options [ 'group' ] ) ? $ options [ 'group' ] : '' ; $ imageData -> original = URL :: to ( $ imageData -> file ) ; $ height = ! empty ( $ options [ 'height' ] ) ? $ options [ 'height' ] : null ; $ width = ! empty ( $ options [ 'width' ] ) ? $ options [ 'width' ] : null ; if ( $ height || $ width ) { $ croppaOptions = ! empty ( $ options [ 'croppaOptions' ] ) ? $ options [ 'croppaOptions' ] : [ ] ; $ imageData -> file = str_replace ( URL :: to ( '/' ) , '' , $ imageData -> file ) ; $ imageData -> file = \ Croppa :: url ( $ imageData -> file , $ width , $ height , $ croppaOptions ) ; } else { $ imageData -> file = $ imageData -> original ; } return $ this -> _renderDisplayView ( $ options , $ imageData ) ; }
Display image, image can be cropped with croppa
@param string $content
@param array $options
@return string
Display image image can be cropped with croppa