gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Create a system for inserting site/post metadata into generic blocks

Open cbirdsong opened this issue 2 years ago • 3 comments

What problem does this address?

A lot of the theme blocks are simply bits of text, like Post Title, Site Title and Site Tagline. Most of these are variations on the heading and paragraph block, but they have lots of individual quirks. For instance, the Site Title and Post Title blocks have a bunch of typography controls that are not available to the Site Tagline or Post Date. Additionally, if I'm creating a theme and I register a style on the heading or paragraph block it can't easily be used for any of these theme blocks unless I register it for all of them.

Lots of similar things are happening with images. The Featured Image block lacks the border radius and resizing options present in the Image Block. Additionally, special-case options to use a post’s featured image are already proposed for every basically other block that accepts an image:

  • #35221
  • #24660
  • #13795

Soon there will be a Post Author Image block, which will face the same issues. This does not seem like a system that will scale.

What is your proposed solution?

Instead of making tons of individual blocks for this sort of thing, it seems like it would be better to create systems for using site/post metadata within existing generic blocks.

For text, if you could just insert text metadata freely (maybe as an inline element?) then any functionality added to the core paragraph/heading blocks or by theme/plugin authors would automatically be available to use with the site title, post title, excerpt, date and anything else.

For images, it would be much cleaner if you could just select the featured image, author image or whatever else as the source anywhere any block accepts an image. A similar solution has been proposed in #31849, but only for the featured image. Ideally, these systems would scale to accommodate additional sources for data instead of narrowly addressing issues related to the featured image.

cbirdsong avatar Jan 06 '22 15:01 cbirdsong