#48164 closed enhancement (fixed)
media_sideload_image should store original URL and optionally check for dupes
Reported by: | dshanske | Owned by: | antpb |
---|---|---|---|
Milestone: | 5.4 | Priority: | low |
Severity: | trivial | Version: | |
Component: | Media | Keywords: | has-patch has-dev-note |
Focuses: | Cc: |
Description
When sideloading a file from a URL, using media_sideload_image, the original URL should be stored as metadata automatically.
The reason for this to be done in Core, as opposed to a plugin, is that the reason why individuals use media_sideload_image is to store a local copy of a file. It should, for copyright and fairness reasons, store where it was originally hosted.
The secondary advantage is the sideload can query existing attachments and not sideload the same file twice.
Attachments (1)
Change History (12)
#1
@
5 months ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 5.4
- Priority changed from normal to low
- Severity changed from normal to trivial
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
6 weeks ago
#3
@
6 weeks ago
- Keywords needs-dev-note added
- Owner set to antpb
- Status changed from new to assigned
Hi @dshanske ! Thank you so much for submitting this patch. It was discussed in the recent media meeting and I am going to work to get this merged before the 5.4 beta. One thing I’ll make an adjustment on the media_sideload_image()
function to give some indication of the new meta field being added. @joemcgill mentioned something like Since 5.4, the original URL of the attachment is stored in post meta
Feel free to do this if you don’t see my patch here yet. I’ll likely get to this early next week.
Here’s that function for handy reference: https://developer.wordpress.org/reference/functions/media_sideload_image/
#4
@
6 weeks ago
I am not sure if I can get to this this week, but I'm glad it made sense to the media team. There's really no way to do this with a hook and I really want to properly attribute my cached copies of images.
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
5 weeks ago
#6
@
5 weeks ago
- Milestone changed from 5.4 to Future Release
This ticket still needs a final patch, and with 5.4 Beta 1 landing tomorrow, this is being moved to Future Release
. If any maintainer or committer feels this can be included in 5.4 or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.
#9
@
3 weeks ago
- Keywords has-dev-note added; needs-dev-note removed
Documentation added in the miscellaneous changes dev note: https://make.wordpress.org/core/2020/02/26/miscellaneous-developer-focused-changes-in-wordpress-5-4/
This ticket was mentioned in Slack in #core-media by pbiron. View the logs.
7 days ago
This ticket was mentioned in PR #190 on WordPress/wordpress-develop by killua99.
40 hours ago
<!--
Hi there! Thanks for contributing to WordPress!
Pull Requests in this GitHub repository must be linked to a ticket in the WordPress Core Trac instance (https://core.trac.wordpress.org), and are only used for code review. No pull requests will be merged on GitHub.
See the WordPress Handbook page on using PRs for Code Review more information: https://make.wordpress.org/core/handbook/contribute/git/github-pull-requests-for-code-review/
If this is your first time contributing, you may also find reviewing these guides first to be helpful:
- FAQs for New Contributors: https://make.wordpress.org/core/handbook/tutorials/faq-for-new-contributors/
- Contributing with Code Guide: https://make.wordpress.org/core/handbook/contribute/
- WordPress Coding Standards: https://make.wordpress.org/core/handbook/best-practices/coding-standards/
- Inline Documentation Standards: https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/
- Browser Support Policies: https://make.wordpress.org/core/handbook/best-practices/browser-support/
- Proper spelling and grammar related best practices: https://make.wordpress.org/core/handbook/best-practices/spelling/
-->
Since #48164(https://core.trac.wordpress.org/ticket/48164) when an image is sideloaded we store the original attachment URL in _source_url. There should be test coverage across this feature that validates that the meta is being properly stored.
@pbiron mentioned in the Media meeting where this was discussed that there are currently no existing tests around the media_sideload_image() function. This would be a great start to getting that covered.
@joemcgill also mentioned that "You may want to consider writing the test in a way that sideloads an image that is already available on the test site."
Trac ticket: https://core.trac.wordpress.org/ticket/49631
This patch needs no unit testing I can think of. It is merely storing information so that we can be sure to attribute images that are passed in by URL. The only question is whether the meta key name is the best one for this.