mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Don't apply auto-sizes if there is no width and add filter for disabling #7812
Closed
joemcgill
wants to merge
10
commits into
WordPress:trunk
from
joemcgill:fix/62413-auto-sizes-without-width
+117
−22
Closed
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
80720a2
Don't apply auto-sizes if there is no width
joemcgill c1a21a0
Fix test
joemcgill 4d4b5aa
Revert change to wp_get_attachment_image
joemcgill f3cf359
Add test for when wp_get_attachment_image doesn't produce a width
joemcgill 05591bb
Improve PHPUnit test
joemcgill 3cfcbe2
Move all processing to wp_img_tag_add_auto_sizes
joemcgill e45b275
Add filter for enabling auto-sizes functionality
joemcgill f07f4d1
Revert "Move all processing to wp_img_tag_add_auto_sizes"
joemcgill bbaed9c
Rename filter and apply in wp_get_attachment_image
joemcgill 214f91d
Remove image parameter from the filter
joemcgill 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1993,8 +1993,14 @@ function wp_img_tag_add_auto_sizes( string $image ): string { | |
} | ||
|
||
// Bail early if the image is not lazy-loaded. | ||
$value = $processor->get_attribute( 'loading' ); | ||
if ( ! is_string( $value ) || 'lazy' !== strtolower( trim( $value, " \t\f\r\n" ) ) ) { | ||
$loading = $processor->get_attribute( 'loading' ); | ||
if ( ! is_string( $loading ) || 'lazy' !== strtolower( trim( $loading, " \t\f\r\n" ) ) ) { | ||
return $image; | ||
} | ||
|
||
// Bail early if the image doesn't have a width attribute. | ||
$width = $processor->get_attribute( 'width' ); | ||
if ( ! is_string( $width ) ) { | ||
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. Is it possible for 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. Fixed in baee465 |
||
return $image; | ||
} | ||
|
||
|
This file contains 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
Oops, something went wrong.
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.
Could consolidate these two if statements, but left it for readability.