[EconomistBridge] Fix if no article image present (#2328)

This commit is contained in:
Bockiii 2022-01-15 06:29:18 +01:00 committed by GitHub
parent 607d9297ff
commit 9dcce0ba1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,8 +99,12 @@ class EconomistBridge extends FeedExpander {
$article = getSimpleHTMLDOM($item['uri']);
// before the article can be added, it needs to be cleaned up, thus, the extra function
$item['content'] = $this->cleanContent($article);
// only the article lead image is retained
$item['enclosures'][] = $article->find('div.article__lead-image', 0)->find('img', 0)->getAttribute('src');
// only the article lead image is retained if it's there
if (!is_null($article->find('div.article__lead-image', 0))) {
$item['enclosures'][] = $article->find('div.article__lead-image', 0)->find('img', 0)->getAttribute('src');
} else {
$item['enclosures'][] = '';
}
return $item;
}