-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Media: send numerical post id when uploading image #57388
Conversation
…ing ids comprising "theme + // + template name".
Added @danielbachhuber, who might know off the top of his head whether the postId still serves the original purpose1 of linking an uploaded media attachment to a post id. Otherwise I can debug later. Footnotes
|
Size Change: +195 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
Flaky tests detected in 0078019. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7335658008
|
Yes, here we go. Right in front my eyes. The |
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.
Thanks for all the effort debugging this one and coming up with a fix @ramonjd 👍
This PR tests as advertised for me.
✅ Can upload an image while editing a template
✅ Can upload image in post editor and post id is included in call
I think I'm still missing something though as to why we have to fall back to passing 0
as the post
value. My understanding is that prior to #55970 no post
value was passed in the site editor.
The change to pass a template's actual numerical ID makes sense though.
Omitting the post
value from additionalData
entirely if no numerical ID is found seems to work still for me locally, but as I said, I must be missing something.
Thanks for testing @aaronrobertshaw As far as I can tell, Core doesn't care whether a post id is sent, though the attachments rest api controller has one in the schema. Through its use of I guess the least we can say about this PR is that it's making the return value consistent 🤷🏻 Still, the question of whether this is the right approach is open. Keen to hear what @fullofcaffeine thinks. |
…tes) doesn't exist.
Thanks for helping test this @aaronrobertshaw If you're fine with update in f44f8fe, I'll merge and continue to troubleshoot |
I have a Jetpack PR with a similar approach. Hopefully it addresses issues there too: |
What?
Follow up to:
When uploading media, send a numerical post ID where possible.
Why?
The apparent purpose of the post id here is so that WordPress can assign media to a parent post.
See:
editorMediaUpload
, which includespost
context for uploads #6231Templates and template parts have string ids comprising "theme + // + template name". Their numerical IDs — the unique ids in the database — are stored in
wp_id
property. So let's send that.How?
Checking for a numerical
id
andwp_id
. If there is none, then don't send additional data.Testing Instructions
As with #57040