Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix attachment selection bug #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

DaveLMSP
Copy link

@DaveLMSP DaveLMSP commented Apr 7, 2015

I've been using Multiple Post Thumbnails v1.6.5 on a project involving a large media library (1500+ attachments) and have run into a bug where the details frequently fail to populate for a selected attachment when opening the MediaModal. After investigating, I determined that this occurs because a selected attachment is added to the frame's selection, but not explicitly fetched. If the selected attachment is included in the initial query-attachments call(s), details populate. If the attachment is not included, details remain blank until the attachment is loaded via a subsequent call.

This fix takes inspiration from the WordPress featured image uploader by explicitly fetching the selected attachment and then modifying the library's comparator so that a selected attachment shows before any other attachments. I also removed some redundant event handling by specifying multiple: false on frame creation and by adding a selected attachment only on frame open instead of open / activate.

DaveLMSP added 3 commits April 7, 2015 15:25
Set multiple: false on frame creation; prevent multiple selection
instead of over-riding user input on select event
Retrieve selected attachment via AJAX so details will populate even if
attachment isn't in initial library query.  Also overload library sort
function so that a selected attachment will always show first in the
library.  Lastly, only add attachment on 'open' event as activate is
redundant.
Restoring select event handler; needed to save attachment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant