Opened 12 years ago
Closed 12 years ago
#27573 closed enhancement (fixed)
Don't re-upload album covers that already exist
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.9 | Priority: | normal |
| Severity: | normal | Version: | 3.9 |
| Component: | Media | Keywords: | has-patch |
| Focuses: | Cc: |
Description
If I drag 5 files that have ID3 tags from the same album into the uploader...
Currently:
5 images are uploaded
What should happen:
We store a hash of the bits with the attachment and check for it before re-uploading the image
Attachments (4)
Change History (15)
This ticket was mentioned in IRC in #wordpress-dev by wonderboymusic. View the logs.
12 years ago
#3
@
12 years ago
I understand why post_content_filtered was chosen, but I don't love it here. It also isn't indexed so it's not a whole lot better than, say, a meta query.
#5
@
12 years ago
27573.2.diff implements this by using get_posts() and a key-only meta_query. Both patches' queries are sub-millisecond. This one is probably preferable because it uses more API and no direct SQL. This code will hardly ever run, so speed arguments may be moot.
#8
@
12 years ago
27573.3.diff 80 seconds before your comment.
#9
@
12 years ago
Rather than 'meta_query' => array( array( 'key' => $hash ) ) we can use 'meta_key' => $hash. That said, I don't really like the idea of an unprefixed md5 hash meta key floating around in the metadata table. This is a situation ripe for 'meta_key' => '_album_cover_hash', 'meta_value' => $hash. Speed is not super-essential here and it is hardly the first barebones meta key/value query we do in the admin.
#10
@
12 years ago
27573.4.diff implements _cover_hash since this also applies to video
Erf, I was about to post almost the same thing -_-'
The difference is I used a filter before the thumbnail creation, so plugins can add a title to the attachment if they want (track title? album title?).
Also, I used a post meta to store the hash, but post_content_filtered seems to be better. Less easy to get but we won't use it every day.