Black Friday sale! Get up to 25% off GP Premium! Learn more ➝

[Support request] Image block defaults

Home Forums Support [Support request] Image block defaults

Home Forums Support Image block defaults

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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 48px

    Following 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,
    Elvis

    #2283361
    David
    Staff
    Customer Support

    Hi 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;
    } );
    #2283810
    Ying
    Staff
    Customer Support

    Hi 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/636

    #2287108
    Elvis

    Thanks Ying, thanks David.
    Ying you are right.
    SizeSlug unfortunately does not work. 🙁

    Will use local patterns here.
    lp
    Elvis

    #2287129
    Elvis

    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.

    #2287219
    David
    Staff
    Customer Support

    Its 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.

    #2287652
    Elvis

    Thanks

    #2288168
    David
    Staff
    Customer Support

    You’re welcome

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