1

I am creating a RSS feed from a news channel and I have gotten it all working except for the news story image which is an assets field. I want to pass the url of the image so I can pull it in via feed me into another craft site. I have looked and I can't find any examples of this working anywhere. Thanks for any help

2 Answers 2

1

If you want to just include the URL of the image in the feed so it can be picked up by Feed Me on another site, I believe you can use the <media:thumbnail> tag:

<item>
    <title>{{ entry.title }}</title>
    <link>{{ entry.url }}</link>
    ...
    <media:thumbnail url="{{ entry.myImageField.one().url }}" />
</item>
1
  • Thanks guys that got me sorted
    – bhackett
    Commented Sep 4, 2023 at 15:15
1

If you are using the template that Craft suggests. Then you can add the image into the tag. In my case the assets field is named "titleImage". I have a transform defined as "gallery" to resize the image down to a sensible size. I'm not sure if you need to include the width/height/alt of the image but I do in case it's useful to the feed reader. I'm not sure if different readers have different specs. This works in the Mac app NetNewsWire.

<description>
    <![CDATA[
    {% set image = entry.titleImage[0] ?? null %}
    {% if image|length %}
        <img src="{{ image.url('gallery') }}" alt="{{ image.caption }}" width="{{ image.getWidth('gallery') }}" height="{{ image.getHeight('gallery') }}">
    {% endif %}
    {{ entry.summary }}
    ]]>
</description>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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