- This topic has 7 replies, 3 voices, and was last updated 1 year, 4 months ago by
David.
-
AuthorPosts
-
July 14, 2022 at 1:24 pm #2282981
Elvis
Hello,
there was this discussion https://wordpress.org/support/topic/default-margins-for-containers/#post-13025697 a while ago.
I would like to have defaults in posts and pages for the image block to be:
centered
large size
padding 48pxFollowing the logic from the discussion I listed above and some more searching i have tried this.
function apuri_generateblocks_spacing( $defaults ) { $defaults['image']['alignment'] = 'center'; $defaults['image']['sizeSlug'] = 'large'; $defaults['image']['paddingTop'] = '48px'; $defaults['image']['paddingRight'] = '48px'; $defaults['image']['paddingBottom'] = '48px'; $defaults['image']['paddingLeft'] = '48px'; return $defaults; } add_filter( 'generateblocks_defaults', 'apuri_generateblocks_spacing' );
I have also tried setting the global styles like this.
add_filter( 'generateblocks_default_block_styles', function( $styles ) { $styles['image']['alignment'] = 'center'; $styles['image']['sizeSlug'] = 'large'; $styles['image']['paddingTop'] = '48px'; $styles['image']['paddingRight'] = '48px'; $styles['image']['paddingBottom'] = '48px'; $styles['image']['paddingLeft'] = '48px'; return $styles; } );
No luck. What am I doing wrong?
Best,
ElvisJuly 15, 2022 at 3:03 am #2283361David
StaffCustomer SupportHi Elvis,
try this:
add_filter( 'generateblocks_defaults', function( $defaults ) { $defaults['image']['alignment'] = 'center'; $defaults['image']['sizeSlug'] = 'large'; $defaults['image']['paddingTop'] = '20'; $defaults['image']['paddingRight'] = '20'; $defaults['image']['paddingBottom'] = '20'; $defaults['image']['paddingLeft'] = '20'; return $defaults; } );
July 15, 2022 at 10:07 am #2283810Ying
StaffCustomer SupportHi Elvis,
The padding default should work, but the alignment or sizeSlug may not work.
It’s a confirmed bug, here’s the issue opened for your reference: https://github.com/tomusborne/generateblocks/issues/636July 19, 2022 at 3:09 am #2287108Elvis
Thanks Ying, thanks David.
Ying you are right.
SizeSlug unfortunately does not work. 🙁Will use local patterns here.
lp
ElvisJuly 19, 2022 at 3:48 am #2287129Elvis
Damn, SizeSlug does not work as local pattern either.
The size is written in the sidebar but not applied unless I set to another, and then go back to that size … like it has to relaod it.July 19, 2022 at 5:49 am #2287219David
StaffCustomer SupportIts a JS Variable and currently those don’t reflect the defaults.
Its on the 1.5.5 milestone so should be fixed on the next update.July 19, 2022 at 10:21 am #2287652Elvis
Thanks
July 20, 2022 at 1:48 am #2288168David
StaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.