Sign in

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

  • This topic has 6 replies, 2 voices, and was last updated 1 year, 11 months ago by .
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #6496
    Avatar photoabacigalupe

    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.

    --
    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!

    #6498
    Avatar photoabacigalupe
    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}}
    

     

    --
    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!

    #6501
    Avatar photoabacigalupe
    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”.

    --
    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!

    #6504
    Avatar photoabacigalupe
    This reply has been marked as private.
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.