Archived topic
Fallback image for dynamic image
9 replies · Started by Kees on October 5, 2022
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.
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 );
Hi,
This does not work. It does not show anything. Can you have another look?
Hi there,
which method dud you use to add the Dynamic Background image ?
Was it using the GP Elements method:
See video. Element with a hook and a custom field.
That link keeps returning: Sorry! Something went wrong on our end. Can you recheck the Loom file ?
And now?
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
Hi,
That is not an option because i have a custom field with acf. And i cant select it there.
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.