In the last two weeks I’ve published two screencasts, both in the same Building a media library series:
📺 Displaying the list of media records
We’re setting up a new route, paginate the records, create and use a JSON resource to select the bits of information we need, and finally loop through the results and display them on the frontend. Pretty basic stuff but had to be done for the continuity of the series.
📺 Filter media records by file type and month
This one is a bit more interesting due to the challenges it presented. We had to figure out how to get generic file types like Video, Archive, Document from specific mime types like video/mp4, application/msword, etc.
Then we made sure to only show options that may return results – no point in showing “Archive” as an option if there are no archive files in the list — or showing “May 2021” as a date option if there were no files uploaded in that month.
We also went over things like creating computed properties to add additional select values, maintain query parameters between requests, use query scopes to filter the records, and other possibly interesting things 😄