-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Full Site Editing: Add image filters to the template content output #36026
Conversation
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
@iamtakashi I've noticed that non explicitly aligned images are always centered in the front end. |
@Copons Hmm, it appears left-aligned to me. Do you have a URL where I can see what you're seeing? |
@iamtakashi Sorry, you're right, I forgot to mention "manually resized images". This is on a non-FSE site using Varia (but the same happens with Maywood): |
@Copons Oh.. nice catch. We need to fix this in Varia and child themes. |
// 11 priority | ||
$content = do_shortcode( $content ); | ||
|
||
$content = prepend_attachment( $content ); | ||
$content = wp_make_content_images_responsive( $content ); |
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.
Non-blocking, but I think we'll probably want to start tracking these as units in the isolated suite on the wpcom side. It makes it much easier to visualize the post_content transform and catch regressions.
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.
Feel free to DM if you need help with test setup.
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.
Tested this on wpcom, but I think this is about right. Some other behavior to note:
- Header images can't be resized past their natural image dimensions
- Also ran into the image alignment issue after resizing (centering when it shouldn't in the published view)
Maybe get a +1 for if the filters look correct
Yup, noted this in an earlier comment: #36026 (comment)
I'll wait for a +1 and meanwhile I'll investigate this:
It might be as easy as having EDIT: ditto for this: it's a theme thing. I'll ship this and open an issue tagging theme folks too. |
ace1da6
to
83bb4da
Compare
This will need changing on the WPCom side as we handle things differently there. The Probably the easiest thing would just be something like: if ( defined( 'IS_WPCOM') && IS_WPCOM ) {
$instance = new WPCOM_Responsive_Images;
$content = $instance->make_content_images_responsive( $content );
} else {
$content = wp_make_content_images_responsive( $content );
} I don't know for sure if that will work, but it should get us on the right track. |
Thanks @mattwiebe, that's a very good suggestion and... there even was a todo comment a few lines above pointing to it! |
83bb4da
to
47f9898
Compare
I've added @mattwiebe's suggestion in 8834b9a. It works on my local environment and also on my sandboxed test site on WPCOM. Trying it was as simple as just manually copying and pasting these few lines of code into: |
|
||
// 11 priority | ||
$content = do_shortcode( $content ); | ||
|
||
$content = prepend_attachment( $content ); | ||
|
||
if ( defined( 'IS_WPCOM' ) && IS_WPCOM && class_exists( '\WPCOM_Responsive_Images' ) ) { |
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.
So far we have tried to avoid adding any Dotcom specific code in the FSE plugin. As a non-blocking suggestion: we could add a filter here and modify the content from dotcom side in our mu-plugin code.
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.
Oooh, very good point!
It's an easy enough change, I'll do it right now!
This now requires D33228-code to work on WPCOM. |
With the filter being in mu plugins, will this PR work for Atomic? (or is this just a workaround for wpcom which isn't the case in Atomic sites?) |
Atomic sites should behave as other self-hosted sites, I don't think they have this Dotcom specific code accessible or running (unless it's explicitly ported via wpcomsh). |
aff59cd
to
18a546f
Compare
@noahtallen what @vindl said. 🙂 Anyway, I think this doesn't depend on the WPCOM diff, and it's good to go now! |
Changes proposed in this Pull Request
the_content
filter functions to the template content output in order to fix how the manually resized images in the template part look on the front end.These are the default
the_content
filters that we should roughly use in FSE, and here are theprepend_attachment
andwp_make_content_images_responsive
functions.Testing instructions
Fixes #36020