Update ‘Default’ Block Style
-
I am trying to programmatically update the default block style of an image block.
When a user updates a custom select dropdown in the editor (using ACF plugin), I trigger a JS function that unregisters the default core/image style, and registers a new one, setting it to the default style.
e.g
wp.blocks.unregisterBlockStyle( 'core/image', [ 'retailResidential', 'weddingsEvents', 'advertisingEditorial'] ); wp.blocks.registerBlockStyle( 'core/image', { name: "weddingsEvents", label: "weddingsEvents", isDefault: true });Then when a user creates a new image block, I want the updated image style class (which should be the default), to be automatically applied to the image.
However, this is not working, and I am unable to programmatically update the default style in this way. If I manually update the default style using the ‘Default Style’ select/dropdown it seems to work for adding additional images, but can not do this with JS.
Any help is greatly appreciated. Thank you for reading.
The topic ‘Update ‘Default’ Block Style’ is closed to new replies.