Add class to image block once floated

In the Gutenberg image block, once the block floats to the left or right, an additional class is added to the fiduge which wraps the img tag.
Can this also be added to the GB image block?
I t would make it easier to add padding and margins via a stylesheet rather than adding it manually to each image.

Thanks
Dan

Hi @Dan,

To clarify, do you want to add a custom class to all GB images through code?

If so, we can use WordPress filter render_block for instance.

thanks @fernandoazarcon2 .
No, what I mean is that if we float a GB image block to the left or right, it should add the relevant class to the figure tag.
Currently, this is the figure tab: <figure class="gb-block-image gb-block-image-bd8f5c39">
I would think adding ‘alignleft’ or ‘alignright’ would be helpful as to adding margins and paddings as needed.

I see. It may be good to raise this as a feature request: Feature Requests - GenerateBlocks Community

added here: Add class to GB image block once floated or aligned

1 Like