The new media library is awesome but its a bit inefficient. When the page loads, it puts ALL MEDIA ITEMS as the default view. Which causes the page to load a LOT of images. I’d like it to default to “Uploaded to this post”.
I’ve tried other solutions, such as changing the default selection Change the default-view of Media Library in 3.5?
But this is done via JS and when there’s a lot of images on the page, it first starts loading the “ALL MEDIA ITEMS” tab and then switches tabs to “Uploaded to this post” so I think the better way to do this would be to reorder the select box so that “Uploaded to this post” is first and the default.
I’m not sure how to go about doing that. Or if its even possible with filters. Would love some feedback from the experts. Thanks!
I was able to answer this via help from a great plugin editor.
This solution doesn’t reorder the select box but instead forces it to only load the “Uploaded to this Post” media by default. I used some of the JS from this post to get the select box to change.
I had some help from the great Sewpafly who develops Post Thumbnail Editor Plugin. he shared a great piece of JS that prevents the load of All Media Items and forces it to load only images Uploaded to this Post by default.
admin.js
functions.php
As a Gist
I dropped that into a JS file and called it in functions.php with the
admin_enqueue_scripts
.Works brilliantly. Hopefully the fine wordpress folks fix this in a upcoming update, but for now Sewpafly has the best solution I’ve found. Thanks again buddy. Hope this helps some other fine folks out there.