private function checkForKnownElements(): ?Image {
        if (!$this->article()->getRawDoc()) {
            return null;
        }

        $knownImgDomNames = self::$KNOWN_IMG_DOM_NAMES;

        $domain = $this->getCleanDomain();

        $customSiteMapping = $this->customSiteMapping();

        if (isset($customSiteMapping[$domain])) {
            foreach (explode('|', $customSiteMapping[$domain]) as $class) {
                $knownImgDomNames[] = $class;
            }
        }

        $knownImage = null;

        foreach ($knownImgDomNames as $knownName) {
            $known = $this->article()->getRawDoc()->find('#' . $knownName);

            if (!$known->count()) {
                $known = $this->article()->getRawDoc()->find('.' . $knownName);
            }

            if ($known->count()) {
                $mainImage = $known->first()->find('img');

                if ($mainImage->count()) {
                    $knownImage = $mainImage->first();
                }
            }
        }

        if (is_null($knownImage)) {
            return null;
        }

        $knownImgSrc = $knownImage->attr('src');

        $mainImage = new Image();
        $mainImage->setImageSrc($this->buildImagePath($knownImgSrc));
        $mainImage->setImageExtractionType('known');
        $mainImage->setConfidenceScore(90);

        $locallyStoredImage = $this->getLocallyStoredImage($mainImage->getImageSrc());

        if (!empty($locallyStoredImage)) {
            $mainImage->setBytes($locallyStoredImage->getBytes());
            $mainImage->setHeight($locallyStoredImage->getHeight());
            $mainImage->setWidth($locallyStoredImage->getWidth());
        }

        return $this->ensureMinimumImageSize($mainImage);
    }
private function checkForKnownElements(): ?Image {
        if (!$this->article()->getRawDoc()) {
            return null;
        }

        $knownImgDomNames = self::$KNOWN_IMG_DOM_NAMES;

        $domain = $this->getCleanDomain();

        $customSiteMapping = $this->customSiteMapping();

        if (isset($customSiteMapping[$domain])) {
            foreach (explode('|', $customSiteMapping[$domain]) as $class) {
                $knownImgDomNames[] = $class;
            }
        }

        $knownImage = null;

        foreach ($knownImgDomNames as $knownName) {
            $known = $this->article()->getRawDoc()->find('#' . $knownName);

            if (!$known->count()) {
                $known = $this->article()->getRawDoc()->find('.' . $knownName);
            }

            if ($known->count()) {
                $mainImage = $known->first()->find('img');

                if ($mainImage->count()) {
                    $knownImage = $mainImage->first();
                }
            }
        }

        if (is_null($knownImage)) {
            return null;
        }

        $knownImgSrc = $knownImage->attr('src');

        $mainImage = new Image();
        $mainImage->setImageSrc($this->buildImagePath($knownImgSrc));
        $mainImage->setImageExtractionType('known');
        $mainImage->setConfidenceScore(90);

        $locallyStoredImage = $this->getLocallyStoredImage($mainImage->getImageSrc());

        if (!empty($locallyStoredImage)) {
            $mainImage->setBytes($locallyStoredImage->getBytes());
            $mainImage->setHeight($locallyStoredImage->getHeight());
            $mainImage->setWidth($locallyStoredImage->getWidth());
        }

        return $this->ensureMinimumImageSize($mainImage);
    }
private function checkForKnownElements ( ) : ? Image { if ( ! $ this -> article ( ) -> getRawDoc ( ) ) { return null ; } $ knownImgDomNames = self :: $ KNOWN_IMG_DOM_NAMES ; $ domain = $ this -> getCleanDomain ( ) ; $ customSiteMapping = $ this -> customSiteMapping ( ) ; if ( isset ( $ customSiteMapping [ $ domain ] ) ) { foreach ( explode ( '|' , $ customSiteMapping [ $ domain ] ) as $ class ) { $ knownImgDomNames [ ] = $ class ; } } $ knownImage = null ; foreach ( $ knownImgDomNames as $ knownName ) { $ known = $ this -> article ( ) -> getRawDoc ( ) -> find ( '#' . $ knownName ) ; if ( ! $ known -> count ( ) ) { $ known = $ this -> article ( ) -> getRawDoc ( ) -> find ( '.' . $ knownName ) ; } if ( $ known -> count ( ) ) { $ mainImage = $ known -> first ( ) -> find ( 'img' ) ; if ( $ mainImage -> count ( ) ) { $ knownImage = $ mainImage -> first ( ) ; } } } if ( is_null ( $ knownImage ) ) { return null ; } $ knownImgSrc = $ knownImage -> attr ( 'src' ) ; $ mainImage = new Image ( ) ; $ mainImage -> setImageSrc ( $ this -> buildImagePath ( $ knownImgSrc ) ) ; $ mainImage -> setImageExtractionType ( 'known' ) ; $ mainImage -> setConfidenceScore ( 90 ) ; $ locallyStoredImage = $ this -> getLocallyStoredImage ( $ mainImage -> getImageSrc ( ) ) ; if ( ! empty ( $ locallyStoredImage ) ) { $ mainImage -> setBytes ( $ locallyStoredImage -> getBytes ( ) ) ; $ mainImage -> setHeight ( $ locallyStoredImage -> getHeight ( ) ) ; $ mainImage -> setWidth ( $ locallyStoredImage -> getWidth ( ) ) ; } return $ this -> ensureMinimumImageSize ( $ mainImage ) ; }
In here we check for known image contains from sites we've checked out like yahoo, techcrunch, etc... that have
known  places to look for good images.

@todo enable this to use a series of settings files so people can define what the image ids/classes are on specific sites

@return Image|null
In here we check for known image contains from sites we ve checked out like yahoo techcrunch etc ... that have known places to look for good images .