Load a default image when not picked

Hi there,

I’m new to Glide and I’m starting with the Instagram look alike template to build my own app. I followed the dedicated tutorial but I still have some issues to do the same and to implement other things.

I wonder how I can proceed to display a default image if the user does not select one with the image picker, not to see a blank square in the feed.

Thanks for your help,
Jérémy

Hi Jeremy,

For this purpose, it’s quite simple.

First, you have the image picker which allows your users to pick a profile image, pointing on a column. OK.

Add a template column in the Glide data editor, containing the image or url of the default picture.

Then, add an if/then/else column in the data editor : if “user image” is empty then “default image” else “user image”. This way, this if column will always contains an image, either the user’s one, either the default one.

In your app, the image component will point on the if/then/else column.

That’s it!

7 Likes

Great quick explanation. I’ve done this in some of my apps and it really gives a way more polished look (as opposed to the first letters of the users’ names). It’s especially awesome when doing a relation to the user profile. Having a default “person icon” next to the name really makes it look like a link to the person’s profile.

Only thing left to refine for profile images is the ability to set an image as the app user’s profile image (for the menu icon and comments icon).

Hi Christophe,

Thank you for your help. It really seem the appropriate answer!
However I can’t manage to do that part : “Add a template column in the Glide data editor, containing the image or url of the default picture.”

How to actually upload the image in the data editor (and not the Google sheet right?)?

Moreover, it seems that the image picker won’t point on the if/then/else column if it is absent from the Google sheet.

Thanks again for your help,

You could do that. I prefer placing the image URL in a sheet of “Resources” that also include my choice component options. Then I use a single value data column to pull in the image.

1 Like

You are trying to place the location of the image from your desktop. You first need to either upload it to google drive and share it to get a public url. Or you could temporarily drag and drop the image into an image component, which will upload the image to glide’s firebase server, or you could temporarily use an image picker component to upload the image. Once the image is uploaded, you will have a url that you can use for the template column.

2 Likes

Exactly! My previous explanation misses this detail sorry :pray:

2 Likes

THis used to work but stopped. Should I do the column and use if then? I had a default pic that is used until the user upload a new one.
Screen Shot 2022-10-15 at 3.43.49 PM

I would personally use an IF column instead of setting a default. Allows you to change that default value quickly without having update existing rows.

Thanks Jeff. I have it set when someone adds a contact that it is a default image. Then when they upload a new photo it updates all the previous pictures with the new one.

Just curious why it stopped working.

So when you submit a new contact, that value isn’t written to the new row?

I have a database where someone may meet someone more than once and it tracks each audition. The default is automatically written so there is always an image with a new contact. Once the user gets a photo of contact then they can edit the image and it updates all related images.

Yes, but can you clarify more on the “stopped working” part? What’s the behaviour now?

As my image shows, it used to have a default image. But the default image no longer shows up When adding a new contact. It adds contact with no image even though default is set.
I tried 2 different urls where I have the image and neither work any more.

So under the hood, it still sets the image link to the right column, but the image can’t be shown on the front end?

Correct the link to default image is correct but it does not appear when I create a new contact.

so long.
this problem still exist.

i have an image on goggle drive, that shared to any who know a link.
this link written in " Default value"

but in new row cell is empty

What component do you use when you mention “default value”? What does your flow look like?

image picker. in right column we have a “default value”.
i don’t get a link from database, i use “custom” and put this link:
https://drive.google.com/file/d/1N_dkX010KdKxA76toKjRKFBjeB3w182t/view?usp=share_link
but after save form (set new column) - all data saved, but not this cell - it’s become empty.