Skip to content

Commit

Permalink
only crawl for image URLs when the feed item permalink is not NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaishiyoku committed May 1, 2023
1 parent 78e2f44 commit 7159cbd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Models/Rss/FeedItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public static function fromZendFeedItem(EntryInterface $zendFeedItem, Client $ht
$feedItem = new self();

$content = html_entity_decode($zendFeedItem->getContent(), ENT_QUOTES | ENT_HTML5, $zendFeedItem->getEncoding());
$imageUrls = $zendFeedItem->getPermalink() ? Helper::getImageUrlsForFeedItem($zendFeedItem->getPermalink(), $content, $httpClient) : new Collection();

$feedItem->setCategories(new Collection($zendFeedItem->getCategories()->getValues()));
$feedItem->setAuthors(new Collection(optional($zendFeedItem->getAuthors(), function ($authors) {
Expand All @@ -341,7 +342,7 @@ public static function fromZendFeedItem(EntryInterface $zendFeedItem, Client $ht
$feedItem->setUpdatedAt($zendFeedItem->getDateModified() == null ? null : Carbon::parse($zendFeedItem->getDateModified()));
$feedItem->setDescription($zendFeedItem->getDescription());
$feedItem->setEnclosureUrl(optional($zendFeedItem->getEnclosure(), fn($enclosure) => $enclosure->url));
$feedItem->setImageUrls(Helper::getImageUrlsForFeedItem($zendFeedItem->getPermalink(), $feedItem->getContent(), $httpClient));
$feedItem->setImageUrls($imageUrls);
$feedItem->setEncoding($zendFeedItem->getEncoding());
$feedItem->setId($zendFeedItem->getId());
$feedItem->setLinks(new Collection($zendFeedItem->getLinks()));
Expand Down

0 comments on commit 7159cbd

Please sign in to comment.