You are here

public function Rss::getImage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-feed/src/Reader/Feed/Rss.php \Zend\Feed\Reader\Feed\Rss::getImage()

Get the feed image data

Return value

array|null

File

vendor/zendframework/zend-feed/src/Reader/Feed/Rss.php, line 379

Class

Rss

Namespace

Zend\Feed\Reader\Feed

Code

public function getImage() {
  if (array_key_exists('image', $this->data)) {
    return $this->data['image'];
  }
  if ($this
    ->getType() !== Reader\Reader::TYPE_RSS_10 && $this
    ->getType() !== Reader\Reader::TYPE_RSS_090) {
    $list = $this->xpath
      ->query('/rss/channel/image');
    $prefix = '/rss/channel/image[1]';
  }
  else {
    $list = $this->xpath
      ->query('/rdf:RDF/rss:channel/rss:image');
    $prefix = '/rdf:RDF/rss:channel/rss:image[1]';
  }
  if ($list->length > 0) {
    $image = [];
    $value = $this->xpath
      ->evaluate('string(' . $prefix . '/url)');
    if ($value) {
      $image['uri'] = $value;
    }
    $value = $this->xpath
      ->evaluate('string(' . $prefix . '/link)');
    if ($value) {
      $image['link'] = $value;
    }
    $value = $this->xpath
      ->evaluate('string(' . $prefix . '/title)');
    if ($value) {
      $image['title'] = $value;
    }
    $value = $this->xpath
      ->evaluate('string(' . $prefix . '/height)');
    if ($value) {
      $image['height'] = $value;
    }
    $value = $this->xpath
      ->evaluate('string(' . $prefix . '/width)');
    if ($value) {
      $image['width'] = $value;
    }
    $value = $this->xpath
      ->evaluate('string(' . $prefix . '/description)');
    if ($value) {
      $image['description'] = $value;
    }
  }
  else {
    $image = null;
  }
  $this->data['image'] = $image;
  return $this->data['image'];
}