[Support request] how do I get the featured image as background image with generateblocks?

Home Forums Support [Support request] how do I get the featured image as background image with generateblocks?

Home Forums Support how do I get the featured image as background image with generateblocks?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1521433
    Joost

    Hi, i’d like to create a header for a custom post type with a featured image as a background image with a post tile, category text over it. How do I pull this dynamic data into the generatepress block?

    #1521568
    David
    Staff
    Customer Support

    Hi there,

    you can add featured image backgrounds in GenerateBlocks 1.2 – its currently available for Alpha testing:

    https://generateblocks.com/generateblocks-1-2-0/

    Post title and Meta is something to come later within GeneratePress Premium

    #1521584
    Joost

    Hi David,

    That is awesome..it’s working like a charm!

    thank you

    #1521773
    David
    Staff
    Customer Support

    Glad to hear that!

    #1630506
    Joel

    Hello, I’m struggling to find this feature…apologies if I’m missing the obvious!

    Thanks

    #1630578
    David
    Staff
    Customer Support

    Hi there,

    the feature was removed from the final release, as we realised it was not the best most future compatible method for doing this… we’re working on dynamic content for GP Premiums Element Block which will support this first, after that we will look at integrating that tech into GB.

    #1630704
    Joel

    Thanks for getting back to me. A bit of a long shot but is it possible to enable Featured Images on Elements? If so I may be able to use Toolset to pull through the Featured Image dynamically but Featured Image doesn’t show as an option when using a Toolset container in Elements presumably because Elements don’t have a Featured Image?

    Many thanks.

    #1630882
    David
    Staff
    Customer Support

    Currently the Featured image is only available within the Header Element.
    It will be added to the Block Element in the next update however.

    You can of course get the Featured Image URL using the get_the_post_thumbnail_url function:

    https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/

    Then simply hook into the WP Head to output the styles for a custom-class eg.

    <?php
    $featured_img_url = get_the_post_thumbnail_url($post->ID, 'full'); 
    if ($featured_img_url) {
    	$style = printf(
    		'<style>.custom-class {background: url(%1$s);}</style>',
    		$featured_img_url
    	);
    	return $style;
    }
    ?>
    #1632235
    Joel

    Thanks David. I’ll take a look at this option until the next update.

    #1632389
    David
    Staff
    Customer Support

    You’re welcome

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