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

Block Bindings: Add support for the Cover block background image #63763

Open
bacoords opened this issue Jul 19, 2024 · 4 comments
Open

Block Bindings: Add support for the Cover block background image #63763

bacoords opened this issue Jul 19, 2024 · 4 comments
Labels
[Feature] Block bindings [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Type] Enhancement A suggestion for improvement.

Comments

@bacoords
Copy link
Contributor

What problem does this address?

Right now you can tie the cover block's image to the featured image, but that's as dynamic as you can get. Cover blocks make great containers for synced patterns and it would be great to be able to have block overrides on the cover block's image. The controls are already in the block toolbar, so it shouldn't require too much UI adjustment.

What is your proposed solution?

Enable block bindings/overrides on the cover block's image ID attribute.

@bacoords bacoords added the [Type] Enhancement A suggestion for improvement. label Jul 19, 2024
@SantosGuillamot SantosGuillamot added [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Feature] Block bindings labels Jul 22, 2024
@bacoords
Copy link
Contributor Author

@SantosGuillamot In response to this comment, do you imagine there being a future abstraction for block bindings that would work for the cover block to opt into? If so, I agree that's worth waiting for. Otherwise, it seems that the way the cover block sets a background image is pretty unique and might always be a little bit hard-coded.

@SantosGuillamot
Copy link
Contributor

I am not familiar with the cover block code, but while working on adding support for some attributes of the image, they could benefit from future set_inner_html or set_outer_html methods from the HTML API. I assumed that, to cover the different use cases, the cover block would need those as well. But I might be mistaken and maybe that's not the case.

@justintadlock
Copy link
Contributor

Just want to echo my support for this specific block to have bindings. It'll open up a lot of custom things I want to do with category/tag/term archives.

I can actually kind of fake this to setting the Cover (outside the loop) to use the featured image, but it's really just using the first post's image if it exists:

author-archive-cover

I have bunches and bunches of other use cases too.

@jptweb
Copy link

jptweb commented Sep 19, 2024

Yes I am also investigating if there is possible or a workaround. Cover images seem like such a common feature most websites have; and they are generally on every page so they really benefit from overrides and syncing. So simply using a non synced pattern means I may need to go and and re-save hundreds of pages to update there style. I am trying to see if it could be possible with block variations as well; look forward to hearing any viable solutions as a workaround.

A hacky approach I had was to make one non synced pattern that holds the cover element, and inside that put the synced content like text etc as overrides. This has worked ok but it looks a little weird in the patterns menu and still could lead to issues if I ever needed to change the non synced cover.

What i'll probably end up doing is just creating my own block.. but I then feel i'm reinventing the wheel as the cover block already does cool stuff like serve different size images on different devices etc; allows you to choose focal point etc.

EDIT i'm also realizing this would be a lot tricker than though as things like focal point would be unique for each cover etc. there would be a lot of overrides! I suppose for now I will follow this tutorial to create gutenberg blocks with dynamic content https://kinsta.com/blog/dynamic-blocks/ but once again then i'm recreating the wheel here :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block bindings [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants