Image optimization - replace original with scaled images - #883
Merged
hi-hai merged 1 commit intoAug 18, 2025
Conversation
lslisa
reviewed
Aug 11, 2025
Tymotey
force-pushed
the
Img_Opm-option_scaled
branch
from
August 12, 2025 05:39
54503c1 to
5191fc9
Compare
hi-hai
reviewed
Aug 13, 2025
hi-hai
reviewed
Aug 13, 2025
Tymotey
force-pushed
the
Img_Opm-option_scaled
branch
from
August 14, 2025 06:04
ca725ca to
77a7343
Compare
hi-hai
reviewed
Aug 14, 2025
Tymotey
force-pushed
the
Img_Opm-option_scaled
branch
2 times, most recently
from
August 14, 2025 15:24
182613e to
1293945
Compare
hi-hai
reviewed
Aug 14, 2025
| // Test if create and image was resized. | ||
| if( "create" === $context && isset($metadata['original_image']) && isset($metadata['file']) && false !== strstr($metadata['file'], '-scaled')){ | ||
| // Get rescaled file name. | ||
| $path_exploded = explode( DIRECTORY_SEPARATOR, strrev($metadata['file']), 2 ); |
Collaborator
There was a problem hiding this comment.
@timotei-litespeed why use DIRECTORY_SEPARATOR?
Contributor
Author
There was a problem hiding this comment.
used '/' instead of DIRECTORY_SEPARATOR to keep constinency
hi-hai
reviewed
Aug 14, 2025
| $rescaled_path = $base_path . $rescaled_file_name; | ||
| $new_path = $base_path . $metadata['original_image']; | ||
|
|
||
| if( is_file( $rescaled_path ) && is_file( $rescaled_path ) ){ |
Collaborator
There was a problem hiding this comment.
@timotei-litespeed Please read Media->info() func and get the idea how to check existence.
Contributor
Author
There was a problem hiding this comment.
made changes to code :)
Tymotey
force-pushed
the
Img_Opm-option_scaled
branch
from
August 14, 2025 15:37
1293945 to
9c8b913
Compare
hi-hai
reviewed
Aug 14, 2025
Collaborator
Tymotey
force-pushed
the
Img_Opm-option_scaled
branch
2 times, most recently
from
August 14, 2025 16:41
b2e830f to
ba6c7cf
Compare
Collaborator
|
Both check existence and rename, you all need use API instead of direct php func. This PR will have to be in v7.5. |
Text review Review fixes Move to Media settings
Tymotey
force-pushed
the
Img_Opm-option_scaled
branch
from
August 18, 2025 16:06
ba6c7cf to
be62b7b
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Allow users to replace original image with the scaled version of image.
Will allow user to change scaled size by using filter
big_image_size_threshold. More info: https://developer.wordpress.org/reference/hooks/big_image_size_threshold/