Editor: Beta (not Classic)
Area: Data Tables, Table View
UI Target: Column (Media Type)
Request: Collapse Option
Feature:
When a user has highlighted an entire column in a Table (the column’s Tab has been left-clicked), AND that column is for storing Media Objects, THEN the user should be able to right-click the column’s Tab to show an extra pop-up menu option, “Display Options”.
This extra option could be a toggle button “Collapse Previews”, or it could be a drop-down menu “Display Options” that lets the user configure how to show Media Objects when viewing a Data Table (Hide(toggle), Icon(size), Thumbnail(size), Original(size)).
Ultimately, this would allow users with heaps of Media Objects in their Tables to toggle them off, and load the table faster with a shorter form factor. You could also make it so, when a user clicks on a Media Object in their Table, it would pop-up on-screen (with a download button, of course) using the preset size parameter they set in the column’s “Display Options”; INSTEAD OF the download option being directly in the Table.
This would drastically increase performance when rendering a Table in the user’s (client) Browser window, as virtually no media or download options would be loaded, but you could also configure it to do so for people with beefier machines.
Expansion:
Now that I’m thinking about it, this seems quite simple to implement as all the functionality is self-contained within the MediaColumn() object that anvil is using to express user’s Data Table Media Columns. It opens a lot of possibilities when returning Media from Table>Server>Client.
You could add a built-in method specifically for getting Media Objects:
user = app_tables.users.get(name="John Doe")
previews = anvil.server.scaler(user['media'], size="thumbnail")
profile_pic = anvil.server.scaler(user['pic'], size="original")
Either the Server could scale the images (which would be expensive), or the Table could just hold two extra images for each media object stored (which is still kind of expensive at first, but less so later).
But why, Jacob?
This would mean that users can focus on high quality media, while Anvil immediately saves an iconified and thumbnailed version of each file.
This could also increase UX for built-in Anvil Themes, like Material Design, as all user media would be automagically sized to fit it’s intended dimensions for a given theme.
Of course, that would require the server to have built-ins for scaling images and videos to preset sizes (icon=(16,16), thumbnail=(128,128), original=(w,h)), but it’s only ever downscaling from the Original copy; which is computationally less expensive than upscaling.
This Server Built-In would require some conditionals when scanning through all the media returned from the data table:
if media = image AND image size < selected size: return “original”
if media = video AND Option = “icon”: return “thumbnail image”
How did we fall so far?
This Feature Request arose when I was having to figure out the best way to store multiple sizes for every image (32, 96, 256 in my case). I tried to save my images to the filesystem with Server Code; Scheduled Task once a month. It took me awhile to realize that Anvil’s Server Modules are decentralized, and can’t actually access your app’s filesystem… because your app is a git repository.
It doesn’t have a file system.
~mind explosion noises~
I tried git cloning, adding all my files, then pushing back to Anvil… but then the editor was almost entirely unusable. Only 65MB in the _/theme/assets/ folder bogged my editor to a grinding halt.
I finally realized that I could probably store the (32x32) icons within my Table without dragging it down too much (2.02MB total), making a convenient query return for each row’s media icon and string name. All other media and json files are stored within a Google Drive. Please specify within the Google Drive docs that all media objects will still lazy load. I have an Icon (Table), Thumbnail (Drive), and Original (Drive) file for every image.
There’s 770 images in my Table at 2.02MB for (32x32) using PIL for scaling, but I could drop that down to less than 1MB if I use pygame scaling. I don’t know Anvil’s allocated space for each user, but it seems like at least the Icon size is doable, or “it wouldn’t cost too much more”; financially or computationally.
NOT giving each user their own persistent file system is one of the reasons why Anvil is at such a good price point. I read on Google that Databases aren’t intended for files like Media, that’s the filesystem’s job. I was confused when I saw that I could make a Media only column… but then I loved it, because it made my life easier, because “At least I can save these icons locally…”, but media is still different than ‘raw data’. Got me thinking, “Maybe it needs some special options since it’s a special type of column.”
I was unsure whether I should post all of this in one or two separate posts, but the Server Built-in is just an expansion of the previous Feature Request, so I’ll just leave it here. At the very least, please make it so users can hide all the media download buttons within a media column within their currently viewed data table; so more rows fit in the browser.
You’re awesome, Anvil!
…and thank you for everything you do for us!