-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Image: Use layout.wideSize
as ResizableBox max-width
#39678
Conversation
I was initially trying to solve #26715, but the image still can go off-canvas on smaller screens. |
Size Change: +19 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
// The block will try to use a wide layout size defined in the `theme.json` | ||
// or fall back to the editor max-width + some wiggle-room. | ||
const maxWidthBuffer = wideSize | ||
? parseInt( wideSize, 10 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wideSize
might not be in px
and that could result to quite unexpected results. Also shouldn't we take into account if an image is inside a container with wideSize
set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wideSize might not be in px and that could result to quite unexpected results.
I didn't know all the theme.json files I checked had px
specified. But it shouldn't be problem all the following will return 1000
:
parseInt('1000rem', 10);
parseInt('1000', 10);
parseInt(1000, 10);
Also shouldn't we take into account if an image is inside a container with wideSize set?
The current implementation has the same issue. Ideally, we want ResizableBox to have max-width: 100%
, but currently, it only accepts px values. Here're some details: #11846 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it shouldn't be problem all the following will return 1000:
Yes, but if we have something like 50%
, it will make the max width 50px
. Maybe we should try to improve when we only have a px value? In addition if the value here is smaller than than the viewport it keeps the image contained and I noticed some distortion of the height in that case when I stop dragging.
Screen.Recording.2022-03-23.at.4.04.16.PM.mov
The video is with wideSize: 500px
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll look into this tomorrow. Thanks, Nik!
What?
PR updates Image block to use
layout.wideSize
fromtheme.json
ResizableBox max-width when available. I also adjusted the ratio for Classic Themes.Why?
Related #11846.
Now that themes can provide value for their wide layout size, I think it makes sense for this value to be the max-width of the resizable area.
How?
Updates
maxWidthBuffer
to uselayout.wideSize
.Testing Instructions
Screenshots or screencast
CleanShot.2022-03-23.at.12.37.49.mp4