Removing images from a list

I’m building a profile page where users can upload 6 images individually.

Each upload button is an image upload element laid over an image and a delete button. Visibility is changed depending on if the picture exists or not. All works well…

The database setup is…
User - Profile Image 1 - image

User - Profile Image 6 - image
User - Profile Images - user-images (user-images is a custom data type holding a list of images which can be used in repeating groups to display all profile images of a user)

The workflow setup is…
A new user-image is created if it doesn’t exist and the image is added to the list of images
The image is added to the corresponding User field (Profile Image 1)
The new user-image is added to the User field (Profile Images)



This works fine. However when it comes to deleting images, I can only remove them from the User table. I’m struggling to find a way to remove the image from user-images list of images.

Can anyone shed some light? or propose a neater way of achieving this effect? If only I could enter the images into a list with a key value for reference… ?

You mean you want to delete the actual file? Or remove the file from the User-images datatype?

To delete the file use the ‘Delete an uploaded file’ action:

To remove an image from the User-images datatype use ‘make changes to a thing’ then ‘Images’, remove, the selected image.

Thanks for the help. I intend on actually deleting the image as it will never be needed again.

I’ve been playing about with your suggestion. When setting the image, i’ve stored the URL of the image in a custom state for testing. Then when I delete the image, I delete an uploaded file as mentioned by its URL. This indeed deletes the file (can no longer see it in a browser window by URL) however the image is still in the Featured Image field in User and in user-images as an image.

I’m not sure if it was obvious but these images are not part of a RG…

You seem to be doing, or trying to do, 3 separate things here: (deleting the file, removing the image from the User-images datatype, and/or removing the image from the User Featured Image field), and it’s not clear which one you’re having the issue with, or why…

Maybe some screenshots of your workflows and database setup would help to clarify the issue you’re having, so people can see exactly what you’re trying to do and where you’re currently going wrong.

So, adding user images via single image upload is working fine, as shown in the image below: (created a new user called second@test.com)

This is achieved with the following Workflows:



Once complete, the database looks like this…

Users:

User-Images:

So that all looks good from this direction. however, deleting is a problem. I am deleting from two places, the User, where it is stored as a single image, and User-Images, where it exists in a list.

I’ve tried removing by URL as shown below:
Screenshot 2021-05-24 at 23.15.15

The featured image in this case becomes empty, because I explicitly set Featured-Image to blank, however the file still exists in the list, and if I wasn’t explicit about forcing Featured-image to blank, it would still be there.

The URL no longer holds the image however and i get the below message which is expected.

Thanks

Ok, so you’re pretty much there…

An image field is saved as the URL of the actual stored file, so if you only delete the file, the field values will still contain the URL, even if the file has been deleted. So regardless of whether or not you delete the file from storage you need to make changes to the 2 things you want to change (the User, and the User-Images) to remove the file URL from the field.

  1. To remove the image from the User Field (Featured Image) you need to set the value to blank, as you’re doing.

  2. Top remove the image from the User-Images list of Images you need to use Make Changes To A Thing and define the specific User-Image to modify (e.g. current user’s User-Images, if that’s how your database is set up). Then just select the field to change (Images) and ‘Remove’ the specific image from the list.

  3. To delete the file entirely, use the ‘delete uploaded file’ action, as you are doing already.

2 Likes

Nailed it. Thanks for your time and patience.

So one of the issues I was having was that I hadn’t set the image groups content type to user-images. Once I did that and followed your instructions, it fixed it. Now it works perfectly. Thanks again.

1 Like

I may have jumped the gun there a little. This solution, or my implementation of it seems to work when only a single image exists in the list. I’ve added and removed a single image at a time from all 6 uploaders and this works fine, as shown in one example:

Featured Image saves


User Images saves

Then tapping Delete

Featured Image Deletes


User Images Deletes

But as soon as there are more than one image in the User Images list, the Featured Images remove ok, but the User Images list of images is untouched, making it get larger as images are added and not being deleted.

The workflow for this is:

Which evaluates to a list of images. So I thought I should filter the list to pinpoint the actual image, but I’m not sure how to approach it…

A failed attempt

Fixed. For anyone else wanting a similar solution for profile images, I had to reference the image stored in the User to delete the image from User Images:

and then empty the image field in User:

hey can i get your instagram i want some personal help with bubble