#52417 closed enhancement (fixed)
Make filename checks less strict in `wp_image_src_get_dimensions`
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
As a follow up to #51865, @ianmjones noted that wp_image_src_get_dimensions
checks for the entire upload path when attempting to get the dimensions of full size images. For many reasons, this check can fail if the path has been changed. To make this less strict, we should be able to check to make sure the basename matches rather than the whole uploads path.
Change History (11)
This ticket was mentioned in PR #972 on WordPress/wordpress-develop by joemcgill.
2 years ago
#1
- Keywords has-patch added
#3
@
2 years ago
Took a look at the patch and it makes sense and looks good to me, @joemcgill ! Tests are passing all around too.
mukeshpanchal27 commented on PR #972:
2 years ago
#4
Hello,
As per the PHP Coding Standards document - https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#yoda-conditions can we use Yoda Conditions here?
if ( strpos( $image_src, wp_basename( $image_meta['file'] ) ) !== false ) {
Replace to
if ( false !=== strpos( $image_src, wp_basename( $image_meta['file'] ) ) ) {
#5
@
2 years ago
- Keywords needs-refresh added
need-refresh
for the patch.
hellofromtonya commented on PR #972:
2 years ago
#7
As per the PHP Coding Standards document - https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#yoda-conditions can we use Yoda Conditions here?
Yoda Conditions doesn't apply in this case. Why? There's no variable on either side of the conditional expression. Instead, the expression compares a boolean literal false
to a final result of the functions.
IMO the code is well-formed and understandable.
#8
@
2 years ago
- Keywords needs-refresh removed
Refreshed the patch to deal with merge conflicts after [50136].
This modifies the check for full size files so that only the basename is compared with the image
src
to avoid misses whenever thesrc
path has been modified.Fixes: https://core.trac.wordpress.org/ticket/52417
Props ianmjones