2012-05-24 44 views
0

我正在使用zend_feed生成Feed,這裏是代碼,它工作正常,但我還需要添加一些關於圖像的更多信息,如何使用Zend_Feed(Zend_Feed :: importArray)在圖像中添加寬度和高度

$feedData = array(
      'title' => $feed->feedParams['title'], 
      'description' => $feed->feedParams['description'], 
      'link' => $feed->getSiteUrl() . $feed->feedParams['link'], 
      'charset' => $feed->feedParams['charset'], 
      'url' => $feed->getSiteUrl() . $feed->feedParams['image'], 
      'ttl' => $feed->feedParams['ttl'], 
      'entries' => $feed->getFeedContent() 
     ); 
$feed = Zend_Feed::importArray($feedData, 'rss'); 

結果是

<image> 
    <url>http://local.here/assets/img/icons/feed.png</url> 
    <title><![CDATA[here Uutiset]]></title> 
    <link>http://local.here/uutiset</link> 
</image> 

,但我需要

<image> 
<url>http://www.edilex.fi/images/rss.gif</url> 
<title>Edilex</title> 
<link>http://www.edilex.fi/</link> 
<width>129</width> 
<height>76</height> 
</image> 

,所以我嘗試這一點,但不工作

$feedData = array(
      'title' => $feed->feedParams['title'], 
      'description' => $feed->feedParams['description'], 
      'link' => $feed->getSiteUrl() . $feed->feedParams['link'], 
      'charset' => $feed->feedParams['charset'], 
      'image' => array(
       'url' => $feed->getSiteUrl() . $feed->feedParams['image'], 
       'width' => 120, 
       'hight' => 130 
      ), 
      'ttl' => $feed->feedParams['ttl'], 
      'entries' => $feed->getFeedContent() 
     ); 
$feed = Zend_Feed::importArray($feedData, 'rss'); 

但它不工作,可以請你說我怎麼能做到這一點

回答

1

看起來不像可選的寬度和高度參數均未Zend_Feed_Rss是大相徑庭

映射

從_mapFeedHeaders摘錄

if (!empty($array->image)) { 
      $image = $this->_element->createElement('image'); 
      $url = $this->_element->createElement('url', $array->image); 
      $image->appendChild($url); 
      $imagetitle = $this->_element->createElement('title'); 
      $imagetitle->appendChild($this->_element->createCDATASection($array->title)); 
      $image->appendChild($imagetitle); 
      $imagelink = $this->_element->createElement('link', $array->link); 
      $image->appendChild($imagelink); 

      $channel->appendChild($image);