FeedWriter\Feed::setImage PHP Method

setImage() public method

Set the 'image' channel element
public setImage ( string $url, string $title = null, string $link = null ) : self
$url string URL of the image
$title string Title of the image. RSS only.
$link string Link target URL of the image. RSS only.
return self
    public function setImage($url, $title = null, $link = null)
    {
        if (!is_string($url) || empty($url)) {
            throw new \InvalidArgumentException('url parameter must be a string and may not be empty or NULL.');
        }
        // RSS feeds have support for a title & link element.
        if ($this->version != Feed::ATOM) {
            if (!is_string($title) || empty($title)) {
                throw new \InvalidArgumentException('title parameter must be a string and may not be empty or NULL.');
            }
            if (!is_string($link) || empty($link)) {
                throw new \InvalidArgumentException('link parameter must be a string and may not be empty or NULL.');
            }
            $data = array('title' => $title, 'link' => $link, 'url' => $url);
            $name = 'image';
        } else {
            $name = 'logo';
            $data = $url;
        }
        // Special handling for RSS1 again (since RSS1 is a bit strange...)
        if ($this->version == Feed::RSS1) {
            $this->data['Image'] = $data;
            return $this->setChannelElement($name, '', array('rdf:resource' => $url), false);
        } else {
            return $this->setChannelElement($name, $data);
        }
    }