You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've started to make the Media Library more usable by (a) creating media categories and tags by default, and (b) enabling storage of media items in folders according to year. There's also a PR to store media files according to media category, though that's incomplete.
There are some more things to do to make the Library as well as it should. At the moment, there's no way to know where a media item is actually used (or if it's used at all). This could be extremely important if we later enable administrators to move the real location of their files. At the moment, moving a file breaks the link from the post to the media file. If, however, we know which posts are affected, we would be able to update such links whenever a media file is moved.
Unfortunately, it would currently require a (very expensive) database query to get the IDs of the posts where a media file is used. Much better would be to store those IDs as an array in the meta for the attachment.
Note that "used" is not the same as "attached". Many files are displayed in the content of posts to which they are not attached.
My thought is that such metadata could be added or updated when any of the following happens:
An upload is attached to a post or page (see the add_attachment hook)
An upload is inserted into post content (see the wp_media_attachment_action filter)
An upload is added or removed to/from a post's content ( see the post_updated hook)
An upload is updated (whether via the list or grid view in the Media Library)
Will you be able to help with the implementation?
I might be able to submit a PR, but I wouldn't object if someone else did it before me!
The text was updated successfully, but these errors were encountered:
On further reflection, I think this would be better done using the new object relationships table in PR #1429. That would enable the data to be accessible both from attachments and from posts or pages.
Context
We've started to make the Media Library more usable by (a) creating media categories and tags by default, and (b) enabling storage of media items in folders according to year. There's also a PR to store media files according to media category, though that's incomplete.
There are some more things to do to make the Library as well as it should. At the moment, there's no way to know where a media item is actually used (or if it's used at all). This could be extremely important if we later enable administrators to move the real location of their files. At the moment, moving a file breaks the link from the post to the media file. If, however, we know which posts are affected, we would be able to update such links whenever a media file is moved.
Unfortunately, it would currently require a (very expensive) database query to get the IDs of the posts where a media file is used. Much better would be to store those IDs as an array in the meta for the attachment.
Note that "used" is not the same as "attached". Many files are displayed in the content of posts to which they are not attached.
My thought is that such metadata could be added or updated when any of the following happens:
add_attachment
hook)wp_media_attachment_action
filter)post_updated
hook)Will you be able to help with the implementation?
I might be able to submit a PR, but I wouldn't object if someone else did it before me!
The text was updated successfully, but these errors were encountered: