TransWikia.com

Inline Styles on all native blocks

WordPress Development Asked by user13989254 on December 31, 2021

Is it possible to apply inline styles to all blocks via filters? Or do only some blocks support it? basically I want to add the ability of adding a background image to a single column.
So I added an extra attribute to store the background img url (named backgroundImg) and tested that its saved.

I am trying to use blocks.getSaveContent.extraProps to apply the background image to the inline style like so..

if ("wp-block-column" === props.className) {
    return lodash.merge(props, {
        style: {
            backgroundImage: "url(" + props.backgroundImg + ")",
        },
    });
}

When I run this however the background IMG url is ‘undefined’. However I have tested and know that props.backgroundImg is being saved. I can add more of my code as needed, but any ideas on why it isn’t applying the saved url?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP