[wp-trac] [WordPress Trac] #10657: Allow many-to-many relationship between posts and attachments
WordPress Trac
wp-trac at lists.automattic.com
Tue Aug 7 14:30:42 UTC 2012
#10657: Allow many-to-many relationship between posts and attachments
-----------------------------+-----------------------------
Reporter: morgansson | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Future Release
Component: Media | Version: 2.8.4
Severity: normal | Resolution:
Keywords: needs-patch |
-----------------------------+-----------------------------
Comment (by aesqe):
I've spent a lot of time thinking about this problem, and, in my
[http://wordpress.org/extend/plugins/file-gallery/ File Gallery] plugin,
this is how I've decided to implement a solution:
- each attachment still has only one parent
- if you want to reuse an attachment - you should duplicate it, especially
if you're running a multi-language site and wish to have different
captions on images, depending on language
- when an attachment is duplicated, it retains all the data from the
original attachment, but the actual attachment file is not duplicated on
the file system
- each duplicate gets a new meta field: "_is_copy_of", which contains the
ID of the original attachment
- each "original" attachment also gets a new meta field: "_has_copies",
which contains IDs of all of its copies
- these two meta fields are there for one reason only: if you want to
delete an "original" attachment, you'll get a warning, giving you a few
options as what to actually do: "delete all attachments and the file",
"delete just the original attachment data, don't touch the file", "cancel"
- if you choose "delete just the original attachment data", the first copy
of the "original" becomes the new "original"
- by default, the copies are filtered out of the media library, but that
can be turned off easily on the settings page
In over two years and after over 100 000 downloads, there haven't been any
complaints about this approach, and I personally don't see any obvious
downside to it. It may sound messy, but it wasn't that difficult to
implement.
I'd be grateful for any comments and suggestions.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10657#comment:15>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list