JavaScript for WordPress Forums Gutenberg Development Inline Styles on all native blocks

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #142308
    Ben Beard
    Participant

    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. Iam about 60% of the way there but can’t figure out how to apply the img URL to the column element

    #142309
    Ben Beard
    Participant

    Sorry, I tried to edit to include more info…

    So I added an extra attribute to store the background img url (named backgroundImg)

    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 + ")",
    			},
    		});
    	}

    What am I missing

    • This reply was modified 2 months, 4 weeks ago by Ben Beard. Reason: typo
    • This reply was modified 2 months, 4 weeks ago by Ben Beard. Reason: made another error
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.