Plugin Support
Alvind
(@alvindcaesar)
Hi there,
The snippet in that topic only works for GB v1 — it won’t work with v2 blocks.
For v2 use this snippet instead:
add_action( 'enqueue_block_editor_assets', function() {
$overrides = [
'largeWidth' => '@media (min-width:1280px)', //desktop
'mediumWidth' => '@media (max-width:1279px) and (min-width:768px)', //tablet
'mediumSmallWidth' => '@media (max-width:1279px)', //tablet & mobile
'smallWidth' => '@media (max-width:768px)', //mobile
];
$script = sprintf(
'wp.hooks.addFilter(
"generateblocks.styles.defaultAtRules",
"my-theme/modify-default-at-rules",
function( atRules ) {
const overrides = %s;
return atRules.map(rule => ({
...rule,
value: overrides[rule.id] || rule.value
}));
}
);',
json_encode( $overrides )
);
wp_add_inline_script( 'generateblocks-styles-builder', $script, 'before' );
});
Important: this change only affects newly inserted v2 blocks. Existing blocks that were added before the snippet won’t have their breakpoints changed automatically.