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

Featured Image block: Allow free-form resizing #27620

Closed
kjellr opened this issue Dec 9, 2020 · 21 comments · Fixed by #31634
Closed

Featured Image block: Allow free-form resizing #27620

kjellr opened this issue Dec 9, 2020 · 21 comments · Fixed by #31634
Assignees
Labels
[Block] Post Featured Image Affects the Post Featured Image Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Needs Design Needs design efforts. [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@kjellr
Copy link
Contributor

kjellr commented Dec 9, 2020

What problem does this address?

When working with in the Query block's grid view, it would be great to allow for themes to set a consistent height/crop for all of the Featured images within.

Example use case, where each image is cropped to a square:

The current lack of dimension controls on the featured image block means individual image aspect ratios are unchanged, causing a bit of a jumpy layout:

Screenshot 2021-05-03 at 11 28 55

What is your proposed solution?

If we enable dimension controls and allow object-fit properties to be configured (defaulting to cover), we can enable some much more coherent and nice layouts. Shown here with some custom border radii applied as well:

Screenshot 2021-05-03 at 11 13 35

Here's what the featured image inspector controls could look like:

Featured Image

This was previously explored in #27545

@kjellr kjellr added [Type] Enhancement A suggestion for improvement. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Block] Post Featured Image Affects the Post Featured Image Block labels Dec 9, 2020
@mapk mapk added the Needs Design Needs design efforts. label Dec 9, 2020
@ntsekouras
Copy link
Contributor

This is related: #24660. There are design explorations as well.

@ianstewart
Copy link
Contributor

Additional example where automatic cropping as an option would be valuable:

image

@annezazu
Copy link
Contributor

To make sure feedback isn't lost from this recent WP Tavern post, I'm sharing here as it's relevant to the discussion above:

There is no way to set the size of the image output by the Post Featured Image block. The only way to get a uniform size at the moment is to pre-crop the images before uploading them to WordPress. There is no reason this should not essentially be a variation of the Image block. The only thing featured images need that is different is the option to link to the post.

This was identified as a current pain point in the FSE experience.

@kjellr kjellr changed the title Allow Post Featured Image blocks to have a consistent height Allow Post Featured Image blocks to be cropped to a consistent height Apr 16, 2021
@kjellr kjellr changed the title Allow Post Featured Image blocks to be cropped to a consistent height Allow Post Featured Image blocks to have a consistent height Apr 16, 2021
@jasmussen jasmussen changed the title Allow Post Featured Image blocks to have a consistent height Featured Image block: Allow free-form resizing May 4, 2021
@jasmussen
Copy link
Contributor

I took the liberty of tweaking the title and content of this ticket a little bit, with some mockup work from the now-closed #31418.

@leph83
Copy link

leph83 commented May 4, 2021

I would add another Setting with a slider where you can adjust the ratio.
And if you add this feature, it would be nice, if you can choose which part of the image should always be visible.
Like the control in the cover block.

@paaljoachim
Copy link
Contributor

paaljoachim commented May 4, 2021

The controls suggested by @kjellr Kjell seems like a good first iteration/version.

Screen Shot 2021-05-04 at 18 32 59

I do have one question. Will the "contain" option in a way crop very tall images? So that all images look nice at the height and width suggested?


We do also have the possibility to use the Focal point picker having a more finetuned selection as @leph83 touches upon.


For a more advanced version we have @shaunandrews Shaun's mockups here: #24660 (comment)
These are more complex. Mockup of controls for the Cover and Group blocks.

@leph83
Copy link

leph83 commented May 4, 2021

@paaljoachim I'm not a huge fan of fixed pixel sizes. It's not responsive.

@jasmussen
Copy link
Contributor

The blue px indicator is meant to be a unit selection dropdown, so you could choose other units, such as %, vw, vh, em, rem, etc.

@leph83
Copy link

leph83 commented May 5, 2021

The blue px indicator is meant to be a unit selection dropdown, so you could choose other units, such as %, vw, vh, em, rem, etc.

So if I have 3 Columns with a picture inside of each, that I wanted to make square I could set the properties to 100% height and 100% Width to achieve that? That would work for me.

I don't see the possibility to choose the object position in your design, when I chose cover as my scaling option. That would be nice to have.

@jasmussen
Copy link
Contributor

So if I have 3 Columns with a picture inside of each, that I wanted to make square I could set the properties to 100% height and 100% Width to achieve that? That would work for me.

Well, if those 3 columns were part of a query, then setting the dimensions of one of the featured images to square would do it for all of them, yes.

I'd agree it would be nice to also have the focal point picker for the featured image block, but I'd think it would be a nice followup to do. Also keep in mind that themes could do it in the manually as well.

@leph83
Copy link

leph83 commented May 5, 2021

Oh I missed the part, where it's a query. This feature would also be amazing for the Gallery Block and the Image Block itself too

@ntsekouras
Copy link
Contributor

ntsekouras commented May 5, 2021

In order to use object-fit here we need to have set a width and a height/min-height. Should we have some defaults like width: 100% and height/min-height: 200px for example? Can we communicate this better by showing/hiding scale controls depending the existence of width and height values?

--edit: Maybe having only a height control makes more sense? Do we have use cases that we would want to restrict featured image's width, especially when the block has another wrapper outside the img element (currently a p)?

Any thoughts?

@jasmussen
Copy link
Contributor

In order to use object-fit here we need to have set a width and a height/min-height.

Excellent point. Without them they aren't that useful. One option: only show the image scaling properties if a width and height have been set:

no dimensions

dimensions

@carolinan
Copy link
Contributor

carolinan commented May 7, 2021

Could the featured image be a variant of the image block, just with a different source?
The image block has more features and is tested, yet, trying to import controls from it to the featured image block or the custom logo has proven to be very difficult.

@ntsekouras
Copy link
Contributor

Could the featured image be a variant of the image block, just with a different source?

I recently made some exploration for making it a block variation of Cover but it needs way more explorations as the flows become difficult to reason with. I'm not sure about the source attribute since this is a dynamic value and haven't worked with this handling before..

I believe landing at least a basic handling for now like the above would be okay for now and gives value, in order to make it to 5.8. I'll have a PR soon for this and we can test how it feels.

@justintadlock
Copy link
Contributor

To make sure feedback isn't lost from this recent WP Tavern post, I'm sharing here as it's relevant to the discussion above:

There is no way to set the size of the image output by the Post Featured Image block. The only way to get a uniform size at the moment is to pre-crop the images before uploading them to WordPress. There is no reason this should not essentially be a variation of the Image block. The only thing featured images need that is different is the option to link to the post.

This was identified as a current pain point in the FSE experience.

I wanted to add some clarification to this since it was added to a ticket about Dimensions. While related, I was specifically referring to the Image Size control (e.g., full, thumbnail, medium, large, custom-theme-size, etc.) and not width/height controls. These are the sizes created via set_post_thumbnail_size() and add_image_size().

This ticket seems to be moving toward a path for dimension and scaling controls, which is great, but I don't want this feature to get lost if it's out of scope for this ticket. I can open a separate ticket if needed.

@jasmussen
Copy link
Contributor

Thank you for the reminder, Justin. Here I included the thumbnail size picker:

Featured Image i3

@melchoyce
Copy link
Contributor

Instead of having to specify an exact width and height by default, it might be nice to explore the ratio picker the image block uses:

image

@antonyjsmith
Copy link

Just to weight in here to provide some end user perspective.

Rolling out a new block which is aimed at replacing blocks like 'Latest Posts' before reaching feature parity is a major pain in the ass as you keep having to relearn stuff, hit brick walls and end up at GitHub, which lets be honest, isn't somewhere your average Joe is going to want to start digging around to find out why they can't change the image size in a significant new feature.

By way of example there are now two blocks to create a grid of posts and one handles featured images better than the other provided it's a post I want to use and not a CPT or Page, if that's the case then I'll have to hard crop them all. This is incredibly frustrating, a waste of time, confusing and tough to explain to an end user.

I just find it a lot of wasted effort to have all this discussion around a completely different implementation when the featured image control works perfectly well in the 'Latest Posts' block and is familiar to a user since it's basically the same as an image block.

Having to relearn an approach with a replacement block and discover limitations, inconsistencies of feature sets to what on the surface appear the same components and lack of feature parity for existing approaches with replacement blocks is a consistent blight on the Gutenberg project.

@mtias mtias added the [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi label Jul 26, 2021
@mtias mtias mentioned this issue Jul 26, 2021
65 tasks
@justintadlock
Copy link
Contributor

Should this ticket be closed by #31634?

I was under the impression that an Image Size control was a part of this, which is why I didn't open another ticket (it would also partially cover @antonyjsmith's concerns). I don't think this is in the PR.

@ntsekouras
Copy link
Contributor

The issue was closed automatically from the PR and addressed the initial proposed enhancements. There are more to come to this block (Featured Image) and we have this issue for consolidating the 'posts list' blocks.

I created a new issue for the image controls here: #33789

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Featured Image Affects the Post Featured Image Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Needs Design Needs design efforts. [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.