public function getImage()
    {
        $this->imageWidth = null;
        $this->imageHeight = null;

        $images = $this->images;
        $bigger = (bool) $this->getConfig('choose_bigger_image');
        $minWidth = $this->getConfig('min_image_width', 1);
        $minHeight = $this->getConfig('min_image_height', 1);

        $images = array_filter($images, function ($image) use ($minWidth, $minHeight) {
            return $image['width'] >= $minWidth && $image['height'] >= $minHeight;
        });

        if (empty($images)) {
            return null;
        }

        reset($images);
        $image = current($images);

        if ($bigger) {
            $sizes = [];

            foreach ($images as $img) {
                $sizes[$img['url']] = $img['size'];
            }

            $biggest = static::getBigger($sizes);

            foreach ($images as $img) {
                if ($biggest == $img['url']) {
                    $image = $img;
                    break;
                }
            }
        }

        $this->imageWidth = $image['width'];
        $this->imageHeight = $image['height'];

        return $image['url'];
    }
public function getImage()
    {
        $this->imageWidth = null;
        $this->imageHeight = null;

        $images = $this->images;
        $bigger = (bool) $this->getConfig('choose_bigger_image');
        $minWidth = $this->getConfig('min_image_width', 1);
        $minHeight = $this->getConfig('min_image_height', 1);

        $images = array_filter($images, function ($image) use ($minWidth, $minHeight) {
            return $image['width'] >= $minWidth && $image['height'] >= $minHeight;
        });

        if (empty($images)) {
            return null;
        }

        reset($images);
        $image = current($images);

        if ($bigger) {
            $sizes = [];

            foreach ($images as $img) {
                $sizes[$img['url']] = $img['size'];
            }

            $biggest = static::getBigger($sizes);

            foreach ($images as $img) {
                if ($biggest == $img['url']) {
                    $image = $img;
                    break;
                }
            }
        }

        $this->imageWidth = $image['width'];
        $this->imageHeight = $image['height'];

        return $image['url'];
    }
public function getImage ( ) { $ this -> imageWidth = null ; $ this -> imageHeight = null ; $ images = $ this -> images ; $ bigger = ( bool ) $ this -> getConfig ( 'choose_bigger_image' ) ; $ minWidth = $ this -> getConfig ( 'min_image_width' , 1 ) ; $ minHeight = $ this -> getConfig ( 'min_image_height' , 1 ) ; $ images = array_filter ( $ images , function ( $ image ) use ( $ minWidth , $ minHeight ) { return $ image [ 'width' ] >= $ minWidth && $ image [ 'height' ] >= $ minHeight ; } ) ; if ( empty ( $ images ) ) { return null ; } reset ( $ images ) ; $ image = current ( $ images ) ; if ( $ bigger ) { $ sizes = [ ] ; foreach ( $ images as $ img ) { $ sizes [ $ img [ 'url' ] ] = $ img [ 'size' ] ; } $ biggest = static :: getBigger ( $ sizes ) ; foreach ( $ images as $ img ) { if ( $ biggest == $ img [ 'url' ] ) { $ image = $ img ; break ; } } } $ this -> imageWidth = $ image [ 'width' ] ; $ this -> imageHeight = $ image [ 'height' ] ; return $ image [ 'url' ] ; }
Gets the best image

@return string|null
Gets the best image