This was an interesting question as I knew nothing about modifying the default behaviour of the Media Library. So, I ended up doing some research on the matter.
I found out that the Media Library uses wp_ajax_query_attachments()
to get the images and other media. Inside the ajax function there’s ajax_query_attachments_args
that can be used to modify the arguments for the attachment WP_Query
.
After the WP_Query
the ajax function uses wp_prepare_attachment_for_js
(function and filter) on the queried posts before they are sent back with wp_send_json_success()
.
Perhaps you could try playing around with wp_prepare_attachment_for_js
filter and see, if you can achieve the result you want.