Default Gallery Settings
-
Is it possible to set the default settings when creating a GutenBee gallery block? For example when creating a GutenBee gallery, if the gallery type could start with Justified, have row height set to 250, margins 10, show captions, and link to the media file by default these make for a beautiful gallery. Each post I create has multiple gallery blocks making it a pain to configure every time. With the native WP gallery block I coded the following for functions.php which sets the default when inserting a block:
function my_block_type_metadata($settings, $metadata)
{
if ($settings['name'] == 'core/gallery') {
$settings['attributes']['sizeSlug']['default'] = 'medium';
$settings['attributes']['columns']['default'] = 4;
$settings['attributes']['linkTo']['default'] = 'media';
}
return $settings;
}
add_filter('block_type_metadata_settings', 'my_block_type_metadata', 10, 2);I tried to code a version for GutenBee but can’t even get a print out of the attributes. I got the name ‘gutenbee/justified-gallery’ from editing a post with Classic Editor. But perhaps the settings name is a little different?
function gutenbee_metadata($settings, $metadata)
{
if ($settings['name'] == 'gutenbee/justified-gallery') {
print_r($settings['attributes']);
}
return $settings;
}
add_filter('block_type_metadata_settings', 'gutenbee_metadata', 10, 2);Any pointers would be greatly appreciated.
Warm regards.
You must be logged in to reply to this topic.