Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

#featuredImage not showing inside #getPostsByTags inside #post post.hbs

  • #6496
    Avatar photo[anonymous]

    Hi!

    Theme is not showing #featuredImage inside #getPostsByTags function at a #post of post.hbs file. Why?

    The structure is:

    Inside post.hbs, there is a #post. Inside I call #getPostsByTags. Then, inside #getPostsByTags I use #featuredImage to show the pic. But is not working.

    Please, help me.

    #6497
    Avatar photoBob

    To see what’s wrong, share your code snippets here.

    #6498
    Avatar photo[anonymous]
    This reply has been marked as private.
    #6500
    Avatar photoBob

    Thanks, I got it.

    I checked it and see that the wrong context was used for the featured image: the src attribute generated the URL to the post instead of the image path. To fix it go to the post.hbs and edit the featured image code snippet by adding `{{#featuredImage}}` context:

    {{#featuredImage}}
       {{#if url}}
          <figure
             class="c-card__image {{@config.custom.cardsImagePosition}} is-img-loading">
             <img
                src="{{url}}"
                {{#if @config.site.responsiveImages}}
                {{responsiveImageAttributes 'featuredImage' srcset.cards sizes.cards}}
                {{/if}}
                {{ lazyload "lazy" }}
                height="{{height}}"
                width="{{width}}"
                alt="{{alt}}">
          </figure>
       {{/if}}
    {{/featuredImage}}
    
    #6501
    Avatar photo[anonymous]
    This reply has been marked as private.
    #6503
    Avatar photoBob

    It works very well, but add a featured image to your post first. All the posts in the “mirada” tag do not have a featured image.

    You can check it right now with a second tag called “portada”.

    #6504
    Avatar photo[anonymous]
    This reply has been marked as private.