-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Ensure post-featured-image block is in_the_loop() for BC with core and plugins, and to fix lazy-loading #45534
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,12 @@ function render_block_core_post_featured_image( $attributes, $content, $block ) | |
| } | ||
| $post_ID = $block->context['postId']; | ||
|
|
||
| // Check is needed for backward compatibility with third-party plugins | ||
| // that might rely on the `in_the_loop` check; calling `the_post` sets it to true. | ||
| if ( ! in_the_loop() && have_posts() ) { | ||
| the_post(); | ||
| } | ||
|
|
||
| $is_link = isset( $attributes['isLink'] ) && $attributes['isLink']; | ||
| $size_slug = isset( $attributes['sizeSlug'] ) ? $attributes['sizeSlug'] : 'post-thumbnail'; | ||
| $post_title = trim( strip_tags( get_the_title( $post_ID ) ) ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we remove the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mamaduka Oh you mean not pass We could do this here and also further down on Do you think I should add it to this PR or rather in a separate PR?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Correct.
We can do it in a separate PR if you prefer.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mamaduka Sounds good, I'll open a follow up PR once this is merged. Is this waiting for anything else or should we merge it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to merge 👍
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's the main reason I'm asking. Is there any way we can cherry-pick / backport this change to core sooner? Happy to help as much as I can.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll have to do a minor release for the packages outside the release scope, but I don't know what's the policy here. I'm going to ping folks who have done more release than me. Cc. @noisysocks, @youknowriad
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is something we do often I think. We'll have to cherry-pick the commits to the right
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, Riad! I'm familiar with the new process and can do a patch release. @felixarntz, I can do a package release and prepare core PR early next week.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect, thanks both! Let me know if I can help with anything like reviews or so. |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.