-
Notifications
You must be signed in to change notification settings - Fork 179
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
Editor: incorrect poster dimensions being returned #12354
Comments
We have a filter in
I think it is a good call. |
Hmm I guess we could do something like this with that filter: add_filter( 'editor_max_image_size', $constrain_dimensions );
$poster_src = wp_get_attachment_image_src( $thumbnail_id, Image_Sizes::POSTER_PORTRAIT_IMAGE_SIZE );
remove_filter( 'editor_max_image_size', $constrain_dimensions ); That seems to work |
I am trying to think of a solution that would work with BC in mind. I was thinking about adding a filter before the preload and remove after preload is finished. Which might fix other issues in the future. |
So basically doing that at a higher level (before the preload) vs. within the controller? |
Yeah, I would have done it in edit-story.php. |
I suppose that could work |
Bug Description
Lucky found this obscure bug where the checklist in the editor shows a warning about incorrect poster dimensions, even though the poster definitely has the right size.
I tracked this down to some unexpected behavior in WordPress that boils down to honoring
$content_width
.This only happens in the admin and not when accessing the REST API in an other way.
Here's how it works:
Stories_Controller
)\Google\Web_Stories\REST_API\Stories_Controller::get_story_poster()
callswp_get_attachment_image_src()
wp_get_attachment_image_src()
in turn callsimage_downsize
image_downsize
in turn callsimage_constrain_size_for_editor
image_constrain_size_for_editor
then reduces the width and height because we're in the admin (is_admin()
is true because of the REST API preloading)To work around this, I think we have to call
image_get_intermediate_size()
to get the actual size ourselves, and if that returnsfalse
(because the size does not exist), get the original size fromwp_get_attachment_metadata()
.But there might be other options.
Notes:
\Google\Web_Stories\Model\Story::load_from_post()
Story
model inStories_Controller
, so we can delete the redundantget_story_poster
method thereAside:
I find it unexpected that
wp_get_attachment_image_src()
honors$content_width
like this. Maybe worth opening a Trac ticket?Expected Behaviour
There should be no incorrect warning.
Steps to Reproduce
Screenshots
Additional Context
The text was updated successfully, but these errors were encountered: