Sign in

Questions about {{#each}} with posts & featuredPosts

#3248
Bob
Support

You can do this by checking the order of the posts and applying the correct image size:

{{#if featuredPosts}}
    <ol class="container">
        {{#each featuredPosts}}
            <li>
                {{#featuredImage}}
                    {{#if url}}
                        <img
                            {{#checkIf @index '==' 0}}
                               src="{{urlLg}}"
                            {{else}}
                               src="{{urlXs}}"
                            {{/checkIf}}
                            {{#if @config.site.responsiveImages}}
                               {{responsiveImageAttributes 'featuredImage' srcset.listing sizes.listing}}
                            {{/if}}
                            {{ lazyload "lazy" }}
                            height="{{height}}"
                            width="{{width}}"
                            alt="{{alt}}">
                    {{/if}}
                {{/featuredImage}}
            </li>
        {{/each}}
    </ol>
{{/if}}

More about the image settings: https://getpublii.com/dev/how-images-work-in-publii/#advanced

--
Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!