How to allow a user to replace a certain image from a list (Picture Uploaders)

Hey!

Basically my users have the ability to upload images for their product, the uploaded products are inputed using 10 picture uploaders, i have already allowed them to add the images, but now i want them to be able to go and edit their images. for example if they dont like image 2 and want to repalce it, i want them to be able to input a new image for #2 and add the new image in place of the one they uploaded previously. I want to also make sure it keeps the same order of 1-10 according to which image they replaced.

A bonus would also be if someone could tell me if there is a way to rearrange these images like in shopify by dragging them around and rearranging the order they are in.

Thank you!

One simple option is to save them to DB and display a draggable repeating group.

But in that case, i would have to save them to a seperate data field and make each image a seperate entry with its own indexes. My images are within the product in “images” and it’s a list of images. I want to be able to allow users to replace one of the images or even rearrange them and saving the new images and the positions back into the products images.

My plugin better uploader allows users to change the order of images before they get uploaded using the ‘Swap’ action.

I’ll take a look at it! I hope it’s free :wink:

1 Like

Would it still work if users want to swap the image itself on an “Edit Item” Page after it has already been saved?

The plugin is useful for when the user is selecting many images at the same time, and then they can reorder, add or remove files from that list. Then, you can upload them all at once in the correct order (only interacting with the database one time).

What you’re talking about here is editing the order after it’s been uploaded. To do that, you can create a state on the page that’s a list of images. To reorder the list, let’s say a user wants to swap image 1 and image 2. Create a new list with image 2 as the first item and image 1 as the second item. The rest of the items are then merged at the end of this list. When the user is done making changes, use “clear list” on the field it’s stores in and then use “set list” to update it :slight_smile:

Another way is to wrap the image in a database thing that has a field called “order”, which you can use to sort the list and modify positions quite easily. Up to you :slight_smile:

Have a great day

Your better uploader is a great plugin!

1 Like

Thank you :slight_smile:

That is such great advice and your plugin is amazing! I am going to attempt what you have advised and let you know how it goes. Thank you so much again for your time!

1 Like

I tried to do this but couldnt acheive it, I added a page where the user uploads their files, but i am making an edit product page where they select their product and can edit for example the order of their image, add images, or even remove images. this is the set up i have, not sure what im doing wrong. Thank you!

This Image is what happens when the user clicks their product to edit

and this is where my delete image button isnt working

and i am still unable to rearrange, thank you for your help!