Looks like your question was answered in a comment https://make.wordpress.org/core/2021/06/25/introducing-theme-json-in-wordpress-5-8/#comment-41667 some hours ago, but adding a link so it’s visible for those who are looking for the same information.
Thanks for the link, but I’m still quite unclear on this.
Per example: is it possible to change the default alignment of a specific block, through the theme.json file? I tried several forms of notation, but didn’t see any differences so far.
Hi @nao,
thanks for the links, I’ve looked through all theme.json files from the themes in the last link. I’ve seen and learned a lot about what’s possible with the theme.json file!
Unfortunately I haven’t seen a property that’d allow the theme.json file to change the alignment of the block itself. Per example: I would like to be able to configure the default size of an image block and set it to ‘Wide width’ or ‘Full width’. See this screenshot:
https://drive.google.com/open?id=1ER25SGree5C8KnecyJrxKv3cUU9E56f0&authuser=dominique%40noesteijver.nl&usp=drive_fs
I see a property textAlign
, but that won’t control the actual width of the block.
-
This reply was modified 2 months ago by ProxxiM.
Hi @proxxim,
At this stage, it’s not possible to set a default “wide” alignment for images via theme.json
.
There could be a few reasons for this. One is that the current approach for the align block support is more than applying a simple style. It also adds a data-align
attribute.
Another is that the image block implements its own handling of alignments. That is, it doesn’t rely on the block support feature.
Also, when selecting either wide or full alignments, the image block will clear its width and height attributes.
In time as more blocks begin to leverage block support features, we’ll gain more and more control through theme.json.
For now though, if you are looking to set a default image alignment, you might be able to achieve that by using Block Filters to set a default on the image’s align
attribute.
I hope that helps clarify things a little.