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

Background Image block support follow-up tasks #54336

Open
42 of 69 tasks
andrewserong opened this issue Sep 11, 2023 · 26 comments
Open
42 of 69 tasks

Background Image block support follow-up tasks #54336

andrewserong opened this issue Sep 11, 2023 · 26 comments
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Needs Design Needs design efforts. [Type] Enhancement A suggestion for improvement. [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues.

Comments

@andrewserong
Copy link
Contributor

andrewserong commented Sep 11, 2023

Related to #16479, following on from #14744.

Now that the background image block support has been introduced in #53934, this issue captures some ideas for follow-up tasks and features.

Prioritized tasks for WP 6.8 and beyond

Prioritized tasks for WP 6.7

Completed for WP 6.6

Completed for WP 6.5


Unprioritized tasks

Background position improvements

  • Allow non-percent-based units (e.g. rem, em, etc)
  • Allow values that are relative to a particular side (see 3-value and 4-value syntax on MDN) to allow for example "4em from top"
  • Improve experience for adding values from an empty state
  • Consolidate controls with those in the Cover block
  • Look into preventing the controls from displaying until a background image is set (e.g. by moving the size, etc controls into a popover)
@andrewserong andrewserong added [Type] Enhancement A suggestion for improvement. [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues. [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels Sep 11, 2023
@jameskoster jameskoster added the Needs Design Needs design efforts. label Sep 11, 2023
@Ren2049
Copy link

Ren2049 commented Sep 12, 2023

Image embeds are vital for prototyping within the block editor (before comitting them to the media library).

@annezazu
Copy link
Contributor

annezazu commented Sep 27, 2023

Pulling from the FSE Outreach Program's Final Touches call for testing, I wondered if the focal point option would eventually be added in as well:

Color adjustments are fine, but having the same background adjustments available as the cover block would be great. Focus point, at least.

& more here:

Here it would be great with similar controls that exist in the Cover block such a focus and color overlay and opacity.

& more here:

The task was fairly straight forward, although I agree with most of the responders here that an image editing toolbar, like the Cover block has, would make a better handle.

Happy to open a separate issue if that's easier!

@andrewserong
Copy link
Contributor Author

andrewserong commented Sep 27, 2023

I wondered if the focal point option would eventually be added in as well:

Oh, yes! It'd be good to have that as an option, too. I've added it to the list in this tracking issue — no need to create a separate issue for it just yet, I think this is a good place to gather together the ideas for now.

Color overlay and opacity.

Color overlay is possibly a little out of scope for the Group block, as it's well handled by the Cover block and would require additional markup to achieve. The main differences between what we can do for the Group vs Cover blocks at the moment is whether the additional styling rules can be applied to a simple outer wrapper (Group block) vs requiring an additional inner wrapper (Cover block).

@eduardozulian
Copy link

eduardozulian commented Oct 13, 2023

I'm +1 a few of the recommendations here. Here's the list I gathered based on stuff we offer for the Cover Block, all of them already shared:

  • Focal point picker
  • Overlay opacity
  • Set as a fixed background
  • Set as repeated background (great for small images that would work as a background pattern)
  • Image filters/Duotone support

@andrewserong I believe you're also aware of Automattic/wp-calypso#82284 but I wanted to move it here just to confirm if the lack of padding on the group block is currently expected or if we should indeed offer a default padding if there is a background image/color.

Thank you!

@andrewserong
Copy link
Contributor Author

Thanks for adding that feedback here @eduardozulian!

I wanted to move it here just to confirm if the lack of padding on the group block is currently expected

Lack of padding on the Group block is expected. The Cover block is a more opinionated block when it comes to adding a background image, and so padding is formally a part of that block's background image implementation. The Group blocks are more general purpose blocks so it's up to the user (or pattern) to add padding when required. There are currently no plans to add padding by default when a user selects a background image.

@webzunft
Copy link

I see that the generated inline style escapes the quotation marks within url(). E.g.,

style="background-image:url('https://example.com/wp-content/uploads/2023/10/img-scaled.jpg');background-size:cover;"

I don’t see this being a standard in core. If it isn’t, could this be changed to using unescaped quotes?

@andrewserong
Copy link
Contributor Author

@webzunft I believe the escaping occurs due to how the attribute is output in server rendering as the HTML Tag Processor internally calls esc_attr when updating an HTML attribute. Is the presence of escaped quotes causing any visual issues on the site frontend for you? The inline styles are only injected at render time, and aren't saved in post content, so it should be possible to make tweaks to how the styles are output in the future.

@webzunft
Copy link

@andrewserong thanks for your reply. The browser (Chrome) correctly renders the output, so no problem there. I have a plugin that changes HTML in the frontend to inject some information (image captions), which broke with these escaped quotes, but nothing I can’t adjust on my end.

@joemcgill
Copy link
Member

I'm currently looking at image optimizations for various blocks in the editor, and wanted to raise the issue here of needing to allow the browser to optimize loading the most appropriate image for the user. For blocks that render images as img elements, WordPress will automatically add srcset and sizes attributes, and possible add loading="lazy" or fetchpriority="high" to optimize resource loading. Coming up with a way of applying resource optimizations to background images would be an important performance improvement.

Related:

@mikemcalister
Copy link

Color overlay is possibly a little out of scope for the Group block, as it's well handled by the Cover block and would require additional markup to achieve.

Not sure if you meant opacity here as well. I'm genuinely curious what the use case is for the group block with a background image but no way to control the overlay?

Groups have content, usually text,and most background images will make text illegible without some way of reducing the brightness. I've created hundreds of patterns, and I can't think of a single use case where I didn't use opacity when using a background image on the cover block.

Unfortunately, background images and the ability to control opacity and background color are inextricably tied together. If we're adding it to groups, for consistency and usability, it has to come with these controls to make it practically usable. It will be an ongoing battle with users for sure!

@andrewserong
Copy link
Contributor Author

andrewserong commented Dec 21, 2023

Not sure if you meant opacity here as well. I'm genuinely curious what the use case is for the group block with a background image but no way to control the overlay?

Great question. In my experience there are heaps!

A good example of use cases for background images that don't require overlay colors are ones that already include transparency within them, or images that folks have selected for their particular content (i.e. I know I'm going to write something with white text, so I'll pick a nice subdued dark image as my background). For examples of some good transparent background images, I've been playing with those at https://www.transparenttextures.com/ and https://www.toptal.com/designers/subtlepatterns/. Many of those sorts of background images require being able to set the image to repeat, which is being worked on over in #57005.

In terms of the user being able to adjust the opacity or overlay of the background image itself from within the editor, I think that's a great idea, it's just not a very simple task to implement within block supports or to enable for the Group block, so for now I think the other block support features are more pressing to implement, as the Cover block can already handle the overlay case.

I'm just one contributor chipping away at this, but in my opinion, I'd go for us building out the remaining features of the background image support that don't require altering markup (as overlay would require injecting an additional element), and to revisit the idea a little further down the track. It would be nice to support opacity/overlay for it eventually, for sure. I've added it as an item to the issue's description 👍

@andrewserong
Copy link
Contributor Author

Update: the background size / repeat controls (#57005) are now available on trunk, so we can now use repeating background textures in Group block backgrounds. Here's one example of how it can look with a transparent texture as the background image, and then using background color to expose a color through that texture:

2023-12-22.12.12.49.mp4

There were some good ideas for UI follow-ups (e.g. #57005 (comment)) that I'm hoping to look into in the new year, along with background position controls.

@djcowan
Copy link
Contributor

djcowan commented Apr 30, 2024

Apologies for the brevity.
I am finding it very difficult to understand the need for the structure of each core block to be different.
A good example is the core/cover block compared with the core/group block
Both blocks offer image support - but in completey different ways.
I'm not a React specialist but aren't components meant to be combined to create larger UI components? Cards and such?
What has happen to ideas and principals like polyphorphism and D.R.Y?
Reading back a 2019 comment i followed to get here; regarding the difference between blocks is filling me with despair.
"Yeah, I'm not sure about this as this will just be a cover block in the end if we do this." @youknowriad
#14744 (comment)
Which leads me to ask "why?" - isn't this the point?
Now i'm going to leave before I start ranting about the need for separation between content, code and the presentation layer.
PS. We are trying to apply css filter functions to elements that use images. This is how I got here. It can't be done in Wordpress. And this fact frustrates me.

@colorful-tones
Copy link
Member

Hi folks,
We are only one week away from the Beta 1 cut-off date for WordPress 6.6. This issue hasn’t seen any movement in a while, so we (the editor triage leads of the 6.6 release) have decided to remove it from the WordPress 6.6 Editor Tasks project board.

@andrewserong
Copy link
Contributor Author

andrewserong commented May 27, 2024

@colorful-tones this issue is under active work, but the work has been updated in the issue description rather than in separate comments here (CC: @ramonjd). In the issue description, there are two tasks yet to be finished for 6.6 (and one of them is a polishing issue, so it might be able to be worked on during the beta period).

Additionally, there are currently two backport PRs underway for backporting site-wide background images with support for theme relative URLs:

Can we re-add this issue to the board, or would it be more helpful adding the specific backports that need to make it in?

There have been quite a few PRs landing for 6.6, but they largely all fall under the umbrella of enabling site wide background images. Hope that helps!

@ramonjd
Copy link
Member

ramonjd commented May 27, 2024

Thanks @andrewserong and @colorful-tones!

This issue hasn’t seen any movement in a while

If you look at the description edit history, it's seen quite a lot action 😄

I'll tentatively add the two backport issues PRs to the board since they're the most important. All the major tasks have been completed for 6.6, with a couple of JS-only package updates to come this week.

Thanks!

@noisysocks noisysocks moved this to 📋 Iteration/Tracking Issues in WordPress 6.7 Editor Tasks Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Needs Design Needs design efforts. [Type] Enhancement A suggestion for improvement. [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues.
Projects
Status: 📋 Iteration/Tracking Issues
Development

No branches or pull requests