At the moment I am working on a medialibrary in the Laravel framework.
I am looking at WordPress with a users-experience point of view.
The tab Media Library shows the images which you can select.
- I’ve checked TWO images (Shift + click) within “Insert Media”
- I switch to “Featured Image” and check ONE image for Featured Image.
- When I switch back at Insert Media it remembers the two previously selected images and forgets the checked Featured Image.
How does WordPress “remember” what images are checked in Insert Media view. Is that a Backbone view they’re using with some data stored in a model? Because each time I switch between Insert Media and Featured Image the UL
element is changing it’s id
attribute: (__attachments-view-xxx)
.
When I just use plain javascript, could I put some ID’s in an associative array instead? It means that each time I switch back to Insert Media, I need to find the corresponding images to re-check them? What if you have hundreds of media-items to search each time…
I have the feeling the Underscore library might be helpfull somehow as a good alternative but haven’t figured out how to use it to make everything as smooth and fast as possible… It looks WordPress isn’t even “refreshing” the media items. Could anyone give me some advice to mimic this behaviour?
A simple way would be:
Of course, I’m sure WordPress is doing something much more refined, like storing a list of all the images it got from the AJAX request as objects, then doing these operations on that list and also showing/hiding items in the gallery view based on what tab you select. But the general idea is the same.