[Support request] Fallback image for dynamic image

Home Forums Support [Support request] Fallback image for dynamic image

Home Forums Support Fallback image for dynamic image

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2364042
    Kees

    Hi,

    i have a generatpress element that i hook before the footer on a page. I have a dynamic image with ACF. How do i set a fallback image?
    I prefer not to use a background image.

    #2364407
    Jean Paiva
    Developer

    Hey Kees,

    If you is using the GenerateBlocks image block, you can use this filter to define a fallback image:

    add_filter( 'generateblocks_dynamic_image_fallback', function( $url ) {
    	if ( ! $url ) {
    		return 'https://picsum.photos/480';
    	}
    
    	return $url;
    }, 10, 1 );
    #2370945
    Kees

    Hi,

    This does not work. It does not show anything. Can you have another look?

    #2370997
    David
    Staff
    Customer Support

    Hi there,

    which method dud you use to add the Dynamic Background image ?
    Was it using the GP Elements method:

    https://docs.generatepress.com/article/dynamic-data/

    #2371000
    Kees

    See video. Element with a hook and a custom field.

    #2371034
    David
    Staff
    Customer Support

    That link keeps returning: Sorry! Something went wrong on our end. Can you recheck the Loom file ?

    #2371036
    Kees

    And now?

    #2371037
    David
    Staff
    Customer Support

    Working now 🙂

    Ok so instead of using the GP Dynamic Image Block.
    Can you use the GenerateBlocks Image Block and using its Dynamic options:

    https://docs.generateblocks.com/article/image-overview/#dynamic-data

    #2371045
    Kees

    Hi,

    That is not an option because i have a custom field with acf. And i cant select it there.

    #2371051
    David
    Staff
    Customer Support

    In the GB Image Block you can enable its Dynamic Data and set the Data Type to: Post Meta, then add your ACF name in the field provided.

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