[Support request] Default Featured image

Home Forums Support [Support request] Default Featured image

Home Forums Support Default Featured image

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2534559
    David

    Hello,

    Im designing a post loop and post template using generateblocks and generatepress. Is there a way of displaying a default featured image if one has not been applied to a post or category without using a plugin?

    Thanks

    David

    #2534600
    Ying
    Staff
    Customer Support

    Hi David,

    There’re two scenarios:

    If you are using a container with a dynamic background image set to the featured image, you just need to upload an actual image, it will be the fallback image if there’s no featured image.

    If you are using a GB image block to pull the featured image, you can add one more image block with the fallback image below it, add a CSS class to the dynamic GB image block, eg. featured-image, so we can use CSS to target it.

    Here’s the block structure for your reference, the red one is the dynamic image, and the green one is the static fallback image:
    https://www.screencast.com/t/ry7zgkE4

    Here’s the CSS:

    .gb-query-loop-item .gb-block-image:has(.featured-image) + .gb-block-image {
        display: none;
    }
    #2534608
    David

    Thank you, that makes sense. I like solution 1 unfortunately I’m using generateblocks images, would have been good to have had that same feature in the image block as the background image in container.

    #2534680
    Ying
    Staff
    Customer Support

    Unfortunately, it’s not available for image block.

    You can try the second solution.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.