I’m using retool storage with the file upload / image upload component. I already enabled the checkbox for optimizing images so they are reduced in size. However, loading those images as a thumbnail or as normal size takes a long time. There’s no loading icon or placeholder until the image is loaded. There’s only a white space.
Is there a way to optimize uploads even further if the camera is used?
Is there an option to load them as a thumbnail from retool storage?
Does anyone have another solution for this? Caching? Workflow? Cdn? Loading svg placeholder?
@Steven_W I've had success using imgix.com in the past. Not an official Retool recommendation, just something I've used at past companies.
You input a public web URL like https://<org>.retool.com/api/file/16260720-39d2-41d2-b2dc-7f3f1fea3be3 and it makes it available at a URL like https://<foo>.imgix.net/16260720-39d2-41d2-b2dc-7f3f1fea3be3, and then you can add query params like ?w=100 to resize it to 100px, etc. Everything is cached under the hood so you only pay the resize cost once.
Thanks. That sounds interesting. I’ll look into it.
One more thing:
When the image is loaded from retool storage, I display it in a custom collection list. As a small thumbnail. When press it, the detail screen is opened. That same image {{item.image}} is used but then bigger. It looks like it loads it all over again. Which is weird because there isn’t another query triggered. I’m using the file ID and not the url.
Would url make a difference in case of retool storage?
Is there a better way to make sure the image doesn’t have to be loaded again if it is already loaded in the list screen?
It looks like Retool Storage images are served with a cache-control header so subsequent fetches should be cached even if you are fetching by file ID and not url.
Without knowing more about your code, I suspect there is some other async processing being done that looks like network fetch but is not -- e.g. under the hood the Image component needs to load the bitmap data for the image, resize it, etc. All that work takes time.
For the source of the detail view and the image component in it I have this:
{{selected_ticket.value.image}}
On the button in the custom collection list I have the click event handler set to “set variable” to set selected_ticket to this:
{{item}}
Here’s a screenrecording:
As you can see, the thumbnail is already loaded.
The only thing I can think of is that I shouldn’t use a variable. But how do I use selected item with a custom collection and a button with event handler? Is there another way to set the selected item?
@Steven_W one idea is to hard-code the image as a base64 string. That way you know the image isn't being served over the network. That'll give you more insight into whether it's a network caching issue or a local rendering issue.
yeahhh same. overall i've been impressed with image loading in our Retool apps (we use CloudFront URLs for S3 objects) but I'd love answers to all those questions too
I guess I will encode the images when the list is loaded and store them in local storage and reference the local storage from the detail screen. I don’t see another option other than getting third party tools involved