Explore adding media
related roles to block attributes
#65186
Labels
[Feature] Block API
API that allows to express the block paradigm.
[Feature] Blocks
Overall functionality of blocks
[Type] Enhancement
A suggestion for improvement.
For a while now we have introduced the
__experimentalRole
property for block attributes. In spite of its name, the feature is considered stable, since it's been in many WP releases.It's usage right now is having a
content
value, that is used in various features like thecontentOnly
mode and pattern transformations. Recently we expanded its usage by supporting alocal
value.This role could be useful for marking some
media
attributes too, and handle cases where we could easily create previews ofmedia
blocks (like Image, Media Text etc..), support more blocks in the post publish panel to upload external images, etc..In order to make some media blocks more semantic, we'd need more than one role though. For start we'd need the
id
and theurl
, which could have different names in blocks. For example theid
in Image block isid
and in Media Text ismediaId
.We will most certainly need a
mediaType
role as well. An example would bevideo and audio
have different tag attributes and a preview for them would have to be generated differently. You can see an example of such handling for media tab in inserter.Finally, right now these attributes have the
content
role assigned and that could simply mean that the new media roles are also considered content. This would require more testing though in order to validate that this is the case for all blocks that use them.The text was updated successfully, but these errors were encountered: