Skip to content
Browse files

Avoid warnings when image element has no title, link, or url attribute

Change-Id: I8b0c84fd8a6c1d83364c09ceb0fdd1156bf2a509
  • Loading branch information...
1 parent 33753c7 commit 80ccd3dbe3f9a4c8bbd0e3231e98d3a9ec6772d4 @richardmansfield committed
Showing with 9 additions and 3 deletions.
  1. +9 −3 XML/Feed/Parser/RSS2.php
View
12 XML/Feed/Parser/RSS2.php
@@ -197,6 +197,12 @@ protected function getImage()
$images = $this->xpath->query("//image");
if ($images->length > 0) {
$image = $images->item(0);
+ $title = $image->getElementsByTagName('title');
+ $link = $image->getElementsByTagName('link');
+ $url = $image->getElementsByTagName('url');
+ if (!$title->length || !$link->length || !$url->length) {
+ return false;
+ }
$desc = $image->getElementsByTagName('description');
$description = $desc->length ? $desc->item(0)->nodeValue : false;
$heigh = $image->getElementsByTagName('height');
@@ -204,9 +210,9 @@ protected function getImage()
$widt = $image->getElementsByTagName('width');
$width = $widt->length ? $widt->item(0)->nodeValue : false;
return array(
- 'title' => $image->getElementsByTagName('title')->item(0)->nodeValue,
- 'link' => $image->getElementsByTagName('link')->item(0)->nodeValue,
- 'url' => $image->getElementsByTagName('url')->item(0)->nodeValue,
+ 'title' => $title->item(0)->nodeValue,
+ 'link' => $link->item(0)->nodeValue,
+ 'url' => $url->item(0)->nodeValue,
'description' => $description,
'height' => $height,
'width' => $width);

0 comments on commit 80ccd3d

Please sign in to comment.
Something went wrong with that request. Please try again.