Alternate default images for profile list

I have a list of student in my app. The teacher sets up the list. Each student’s profile has an image. When there is no image for a student profile, a default is provided using If-Else-Column as described here: Add default picture URL to profile page.

However, if I have 5 students all having the same profile picture, the student list looks pretty boring. Is there a way to randomly or sequentially select the default image from a list?

I was trying to do something like:

if(image is empty AND name starts with “A”) then image A
if(image is empty AND name starts with “B”) then image B

However, I could not figure out how to do the AND in the IF condition.

Anybody has a workaround?

Yes! I was just researching this yesterday. There are avatar generators out there that will output a unique avatar based on text (so as long as there’s text to go off of —user name, eg.— each user can have their own, unique, default avatar).

eg. https://www.tinygraphs.com/

If you look at my Avatar Builder concept app, you can see that I built in new functionality to create one within Glide. However, you can simply prepopulate avatars using a name or email address as part of the tinygraph avatar template.

1 Like

Thanks. Interesting idea. I presume you are planing for the teacher to select the parameters that are included in the URL?

I was hoping we could just call the URL and it would return a different image either per user or each time it is called. I tried this service: https://source.unsplash.com.

Unfortunately, Glide caches the image per URL. That means once I get an image, it will be reused by Glide over and over again.

That’s correct. It’s just using a template column that combines the URL with the user parameters to form a unique URL per user. I wonder if Unsplash has something similar…trouble is, it would need to ensure that it’s school appropriate :grin:

Could try https://source.unsplash.com/featured/?cat,USERNAME …that should be safe…

But how do I add the username to the url dynamically in the If-Else-Column?

You don’t. You create a template column first. In the example of the Adorable.io, the URL is as follows: https://api.adorable.io/avatars/285/KEYWORD.png

In a template column, I’ll just replace KEYWORD with the username or email address. Then, use the template column in the if-then-else column.

Thanks a lot @Robert_Petitto. Glide doesn’t like URL with commas. So unsplash is a no go. I will go with adorable.io for now.

1 Like