Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.