Change image tag to enclosure tag

Many RSS feed readers prefer the **enclosue** tag instead of  **image** tag. The enclosure tag is a generic tag for any type of media.
I tried to make it most simple and universl possible.
This commit is contained in:
angerangel 2021-06-21 11:00:33 +02:00 committed by GitHub
parent aa1dee1d30
commit 20d2a17701
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,8 +74,10 @@ class pluginRSS extends Plugin {
$page = new Page($pageKey);
$xml .= '<item>';
$xml .= '<title>'.$page->title().'</title>';
$xml .= '<link>'.$this->encodeURL($page->permalink()).'</link>';
$xml .= '<image>'.$page->coverImage(true).'</image>';
$xml .= '<link>'.$this->encodeURL($page->permalink()).'</link>';
$imagepath = parse_url($page->coverImage(true), PHP_URL_PATH);
$imagepath = $_SERVER['DOCUMENT_ROOT'] . $imagepath;
$xml .= '<enclosure url="'.$page->coverImage(true). '" filesize="'.filesize($imagepath) .'" type="'.mime_content_type($imagepath) .'" />';
$xml .= '<description>'.Sanitize::html($page->contentBreak()).'</description>';
$xml .= '<pubDate>'.date(DATE_RSS,strtotime($page->getValue('dateRaw'))).'</pubDate>';
$xml .= '<guid isPermaLink="false">'.$page->uuid().'</guid>';