Render NamedBlogImage in template using rapido

I have a list of news items which I need to create a rapido view for. The title and description of the news item are displayed ok, however, the image doesn't. It show's the image object or the name of the image without it being displayed correctly.

Here's the code:

def foxynews(context):
content = context.portal['foxynews']
# content = subcontext.content
items = content.listFolderContents(
    contentFilter={"portal_type" : "News Item"}
return [{
          'description': item.description,
          'image': item.image
} for item in items]

<div class="gl-container">
<div class="content-item" tal:repeat="programme elements/programmes">
    <a class="content-item-wrapper w-inline-block" tal:attributes="href programme/url">
        <div class="content-item-image-holder">
          <img class="content-item-image"
            tal:attributes="src string:${programme/url}/@@image/${programme/image/filename}"
        <div class="content-item-text-holder">
            <h2 class="content-item-heading" tal:content="programme/title" ></h2>
            <div class="content-item-description" tal:content="programme/description" ></div>


    type: BASIC
1 Like

If you use the @@images view (note the final 's'), you do not need the image filename, the field identifier is enough (for a News Item, the image field is named image).
So change the img src attribute in your .pt like this:

src string:${programme/url}/@@images/image

It will be the full original image, but you can also specify the size like this:

src string:${programme/url}/@@images/image/thumb

1 Like