Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media & Text block: wide alignment is not being passed to render_block filter #16365

Closed
webmandesign opened this issue Jun 30, 2019 · 5 comments
Labels
[Block] Media & Text Affects the Media & Text Block [Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.

Comments

@webmandesign
Copy link
Contributor

webmandesign commented Jun 30, 2019

Describe the bug
Looking at the block attributes passed to render_block filter, the align attribute is not set even if the wide alignment is chosen in the editor for Media & Text block.

Maybe caused by wide alignment being a default value for Media & Text block?

To reproduce
Steps to reproduce the behavior:

  1. Insert a Media & Text block into post content, set an image and text. Do not tweak any other options - the block should have wide alignment applied by default.
  2. Publish the post.
  3. Check the output of the $block parameter of render_block filter (in front-end). You can see there is no align attribute under $block['attrs'].

Expected behavior
Alignment value should be passed to render_block filter even if the block uses a specific alignment value by default. (Actually, all default values of block attributes should be passed into render_block filter.)

Additional context

  • Tested on WP 5.2.2
@swissspidy swissspidy added [Block] Media & Text Affects the Media & Text Block [Type] Enhancement A suggestion for improvement. [Feature] Block API API that allows to express the block paradigm. labels Jul 1, 2019
@jorgefilipecosta
Copy link
Member

Hi @webmandesign, thank you for reporting this issue. The issue is happening because wide align is the default align attribute for media & text bloc. The problem is common to all default attributes in every block.
Previously default attributes were not passed to render_block because the server may have not been aware of them. With the block.json work maybe we can now pass default values when they are known on the server. Any thoughts on this @gziolo?

@webmandesign
Copy link
Contributor Author

Thanks for the info @jorgefilipecosta
I thought it could be the case. Would be really great if default atts could be passed to the render_block filter. They are significant part of the block appearance.

@gziolo
Copy link
Member

gziolo commented Jul 19, 2019

Previously default attributes were not passed to render_block because the server may have not been aware of them. With the block.json work maybe we can now pass default values when they are known on the server. Any thoughts on this @gziolo?

The long term idea is to register all core blocks on the server using block.json. It will solve the issue for all the regular attributes but not necessarily for align which is kind of special when used through supports: align construct. We will still have to develop the compatibility layer which will inject this attribute on the server for all those blocks which will enable support: align.

@carolinan
Copy link
Contributor

Hi @webmandesign I am not able to reproduce this with WP 6.2.2 and Gutenberg trunk, is this still an issue?
The block is not wide by default anymore, but when an alignment is used, I see the attribute when I dump the result of the render_block.

@webmandesign
Copy link
Contributor Author

Hi @carolinan I guess this is resolved now after those years ;) You can close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Media & Text Affects the Media & Text Block [Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants