-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix first image lazy loading with block themes #3538
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
Closed
adamsilverstein
wants to merge
3
commits into
WordPress:trunk
from
adamsilverstein:fix/lazy-load-on-block-themes
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There are several places we could adjust for block theme behavior, what do you think @felixarntz?
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.
@adamsilverstein When is the
$contextfalse here? Does the post content in a block theme not go throughthe_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.
when a block theme is enabled,
the_contentfilter is applied to the content with$contextfalse which appears to happen before the main application of the filter. I'm going to dig a bit further to see why that is happening, maybe we can avoid it in the first place.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.
Probably this:
wordpress-develop/src/wp-includes/blocks/post-content.php
Line 55 in 874aa24
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.
@adamsilverstein Hmm that code doesn't look odd to me. The
$contextis never explicitly specified in that filter, it usescurrent_filter()by default, which means here it should be set tothe_content. This would only be a problem if some core code calledwp_filter_content_tags()directly without the parameter (i.e. outside of a filter).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.
indeed I verified that isn't the problem, I'm going to dig in more to trace back and find where the false context value is coming from.
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.
@felixarntz I dug in a bit further here...
wp_filter_content_tagsis called several times by block themes in two places: in
src/wp-includes/blocks/template-part.php::render_block_core_template_partwith no context andcurrent_filterreturning false.Removing this call fixed the issue (but I don't think we can do that):
wordpress-develop/src/wp-includes/blocks/template-part.php
Line 137 in 20bccea
note: also called in
src/wp-includes/block-template.phpinget_the_block_template_html:wordpress-develop/src/wp-includes/block-template.php
Line 244 in 5eddc8f
I considered some other fixes but the check in the current PR seemed the most reliable, what do you think?
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.
Sample trace: