public function getCoverImage()
    {
        if ($this->getValueSet() !== null) {
            foreach ($this->getValueSet()->getValues() as $value) {
                if ($value instanceof MediaValue &&
                    false !== $media = $value->getMedias()->first()) {
                    return $media->getReference();
                }
            }
        }

        foreach ($this->getBlocks() as $block) {
            $reflect = new \ReflectionClass($block);

            if ($reflect->hasProperty('media') && $block->getMedia()) {
                return $block->getMedia()->getReference();
            }
        }

        return false;
    }
public function getCoverImage()
    {
        if ($this->getValueSet() !== null) {
            foreach ($this->getValueSet()->getValues() as $value) {
                if ($value instanceof MediaValue &&
                    false !== $media = $value->getMedias()->first()) {
                    return $media->getReference();
                }
            }
        }

        foreach ($this->getBlocks() as $block) {
            $reflect = new \ReflectionClass($block);

            if ($reflect->hasProperty('media') && $block->getMedia()) {
                return $block->getMedia()->getReference();
            }
        }

        return false;
    }
public function getCoverImage ( ) { if ( $ this -> getValueSet ( ) !== null ) { foreach ( $ this -> getValueSet ( ) -> getValues ( ) as $ value ) { if ( $ value instanceof MediaValue && false !== $ media = $ value -> getMedias ( ) -> first ( ) ) { return $ media -> getReference ( ) ; } } } foreach ( $ this -> getBlocks ( ) as $ block ) { $ reflect = new \ ReflectionClass ( $ block ) ; if ( $ reflect -> hasProperty ( 'media' ) && $ block -> getMedia ( ) ) { return $ block -> getMedia ( ) -> getReference ( ) ; } } return false ; }
Finds first available image for listing purposes.

@return bool
Finds first available image for listing purposes .