Fix: Store scaled image URL for file fields when WP 5.3+ big image scaling is active#2931
Open
masteradhoc wants to merge 3 commits intoAutomattic:trunkfrom
Open
Fix: Store scaled image URL for file fields when WP 5.3+ big image scaling is active#2931masteradhoc wants to merge 3 commits intoAutomattic:trunkfrom
masteradhoc wants to merge 3 commits intoAutomattic:trunkfrom
Conversation
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.
Fixes #1973
Changes Proposed in this Pull Request
Added an optional
&$actual_urlby-reference parameter tocreate_attachment().When WordPress 5.3+ scales a large image during
wp_generate_attachment_metadata(),the metadata will include
original_imageand_wp_attached_filewill point to the-scaledversion.actual_urlis set viawp_get_attachment_url()in that case,giving callers the canonical URL WordPress has stored.
Moved attachment creation inline within the field loop in
update_job_data(), beforeupdate_post_meta()is called. This ensureswp_generate_attachment_metadata()runsfirst, so any scaled URL is resolved before being persisted to post meta — fixing both
the served image (full-res was used instead of scaled) and
attachment_url_to_postid()failures (stored URL didn't match the scaled URL WordPress recorded internally).
Testing Instructions
submission form.
-scaledversion of the image, notthe original.
attachment_url_to_postid()returns the correct attachment ID for the stored URL.Release Notes
WordPress 5.3+ big image scaling was active, causing oversized images to be served and
breaking attachment ID lookups.
New or Updated Hooks and Templates
Deprecated Code
Screenshot / Video