Media Library - Attached/Unattached logic is flawed
|Reported by:||hailin||Owned by:|
In 2.7 Media Library, the tabs Attached, Unattched logic has an issue , and can cause user confusions and wrong output.
Current ‘Attached’ logic:
From Write post panel, user clicks upload media, the the url will contain post_id, which is used to set post_parent for the uploaded attachement.
Then the uploaded image’s post_parent field is set to 8, and as long as post_parent is >=1, the attachment is regarded as “Attached”. Otherwise, it’s “Not attached”.
When an image is added via “Media=>Add New”, then its post_parent is not set, thus the image will be “Unattached”. No subsequent operation will alter its’ post_parent, even when user inserts the image into a post.
So if users always upload images/videos via Media=>Add New, then insert them into posts later, those images/videos will always be classified as “Unattached”, this can cause confusion as users may intend to delete those “unattached, thus unused” things.
I think a better logic for “attached/unattached” would be actually scanning posts contents for inclusion. Basing this logic on a particular operation flow is problematic and it’s difficult to guarantee the correctness.