Opened 9 years ago
Closed 7 years ago
#43579 closed enhancement (fixed)
Optional post_id param in media_sideload_image and media_handle_sideload function
| Reported by: | sebastian.pisula | Owned by: | antpb |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.3 |
| Component: | Media | Version: | |
| Severity: | normal | Keywords: | has-patch needs-testing |
| Cc: | Focuses: |
Description
I think that post_id param in media_sideload_image and media_handle_sideload function should be option optional.
media_sideload_image() call media_handle_sideload() with post_id and this function get current time $time = current_time( 'mysql' ); if post date not exists.
Sa this param can be optional.
Attachments (4)
Change History (12)
This ticket was mentioned in Slack in #core-media by mike. View the logs.
7 years ago
#4
@
7 years ago
- Keywords needs-testing added
- Milestone Awaiting Review → 5.3
- Owner set to
- Status new → assigned
- Type feature request → enhancement
Hi @sebastianpisula ! Thanks for contributing this patch. It is a great change. This was also worked on in #38959 and was discussed in the most recent media meeting. We agree that the solution is sound and that it should move forward in the 5.3 milestone. I'll be testing it in the coming week and will work to commit it.
Just wanted to leave this comment to document the work that @dotancohen did in #38959 . You both came to the very same solution and the Media team thinks you should both get props for it. I'm going to make sure that happens. :)
Thanks again, and more info to follow soon as I test.
This ticket was mentioned in Slack in #core by antpb. View the logs.
7 years ago
#6
@
7 years ago
Coming from #core to give a second committer opinion as requested :)
Since $post_id is eventually passed as `post_parent` to wp_insert_attachment(), I think the default value of $post_id = 0 would be more appropriate. It would match the documented type (int) and would also be more consistent with the rest of core (~33 instances of $post_id = 0 vs. ~9 of $post_id = null). In get_post(), both values are treated the same way.
Looks good otherwise.
#7
@
7 years ago
In my attached patch, 43579.3.diff, I made the default value 0 as per @SergeyBiryukov recommendation. I also added @since docs.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
#38959 was marked as a duplicate.