mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-16 07:09:54 +03:00
[PicalaBridge] Fix article without image (#3429)
Co-authored-by: Clement Desmidt <clement@desmidt.fr>
This commit is contained in:
parent
ca351edbfe
commit
e859497d6a
1 changed files with 16 additions and 7 deletions
|
@ -58,17 +58,26 @@ class PicalaBridge extends BridgeAbstract
|
|||
{
|
||||
$fullhtml = getSimpleHTMLDOM($this->getURI());
|
||||
foreach ($fullhtml->find('.list-container-category a') as $article) {
|
||||
$srcsets = explode(',', $article->find('img', 0)->getAttribute('srcset'));
|
||||
$image = explode(' ', trim(array_shift($srcsets)))[0];
|
||||
$firstImage = $article->find('img', 0);
|
||||
$image = null;
|
||||
if ($firstImage !== null) {
|
||||
$srcsets = explode(',', $firstImage->getAttribute('srcset'));
|
||||
$image = explode(' ', trim(array_shift($srcsets)))[0];
|
||||
}
|
||||
|
||||
$item = [];
|
||||
$item['uri'] = self::URI . $article->href;
|
||||
$item['title'] = $article->find('h2', 0)->plaintext;
|
||||
$item['content'] = sprintf(
|
||||
'<img src="%s" /><br>%s',
|
||||
$image,
|
||||
$article->find('.teaser__text', 0)->plaintext
|
||||
);
|
||||
if ($image === null) {
|
||||
$item['content'] = $article->find('.teaser__text', 0)->plaintext;
|
||||
} else {
|
||||
$item['content'] = sprintf(
|
||||
'<img src="%s" /><br>%s',
|
||||
$image,
|
||||
$article->find('.teaser__text', 0)->plaintext
|
||||
);
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue