0

A site (running EE 2.11.1) I am working on has the following RSS feed code:

{preload_replace:master_channel_name="blog"}
{exp:rss:feed channel="{master_channel_name}"}

<?xml version="1.0" encoding="{encoding}"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>

    <title>The corecubed Blog</title>
    <link>{channel_url}</link>
    <description>{channel_description}</description>
    <dc:language>{channel_language}</dc:language>
    <dc:creator>{email}</dc:creator>
    <dc:rights>Copyright {gmt_date format="%Y"}</dc:rights>
    <dc:date>{gmt_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
    <admin:generatorAgent rdf:resource="http://expressionengine.com/" />

{exp:channel:entries channel="{master_channel_name}" limit="10" dynamic_start="on" disable="member_data|pagination"}
    <item>
      <title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
      <link>{title_permalink='blog/entry'}</link>
      <guid>{title_permalink='blog/entry'}#When:{gmt_entry_date format="%H:%i:%sZ"}</guid>
      <description>{exp:xml_encode}{blog_body}{/exp:xml_encode}</description>
      <dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}, {/categories}{/exp:xml_encode}</dc:subject>
      <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
    </item>
{/exp:channel:entries}

    </channel>
</rss>

{/exp:rss:feed}

Each blog entry has a photo associated with it and I would like to add it to the fee. I tried adding it using the following:

<![CDATA[<img src="{blog_image}" alt="{title}">]>

But that broke the feed.

Any suggestions would be helpful.

  • "Broke the feed"? Broke how? – Robson Sobral Sep 7 '16 at 11:58
  • None of the content after that line of code shows up any more. – forrest Sep 7 '16 at 15:05
1

your simple typo

<!\[CDATA\[ is closed with two brackets, ]]>, not one, ]>. ;-)

a full explanation

Inside the desciption element, you can use HTML within a <![CDATA[:

<description><![CDATA[
    <img src="{blog_image}" alt="{title}">
    <hr />
    {blog_body}
]]></description>

Also, the enclosure element can be use to describe "a media object that is attached to the item". But not all parsers read it.

{blog_image}
    <enclosure url="{site_url}{url}" length="{file_size}" type="{mime_type}" />
{/blog_image}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.