I have a custom post with a repeating field, it is an image field, as WP-Types doesn't provide the drag and drop function to the image upload, I do my own script to handle the image upload. Now I want to change the repeating image field to single. Is there any impact if I do? Will the image be lost after I change?
Let's say you have a post with 4 images in the repeating field. Then you change from repeating field to single field. Immediately after that, the database still contains all 4 field values in postmeta. However, if you edit the post only the first value will be displayed. Then if you save the post again, only the first field will be saved. The other 3 values will be deleted from the postmeta table, but the image will remain in the Media Library until you delete it permanently from the Media Library.
I can't say whether or not there will be a significant impact to the custom upload process you have implemented.
Thanks for your reply. As I know, when I add photo via the repeating field, it will also create the thumbnail image, may I know whether the thumbnail image will be deleted if I remove it via the CRED form?
I want to remove all repeating image except the first one, does Toolset has such script or function that I can do?
Deleting a custom field image using CRED does not delete the image from the Media Library or from your server, it only clears the custom field value. The original image and any resized versions still exist on the server. To delete the original image and its resized images, you must do that manually in the Media Library or use custom code.
What do you mean deleting a custom field image using CRED does not delete the image from the Media Library? Do you mean the CRED only delete the post meta from the database?
I tried to change the repeating field to a single field, I can't see all the image including the first one from the CRED form, I need to remove all repeating images except the first one before changing the repeating field to a single field, what should I do before changing the field?
What do you mean deleting a custom field image using CRED does not delete the image from the Media Library? Do you mean the CRED only delete the post meta from the database?
Yes that is exactly what I mean.
I tried to change the repeating field to a single field, I can't see all the image including the first one from the CRED form,
Change the repeating field to a single field, then resave the post to reset the custom field value. Then it should appear as expected in the Edit Post Form.
I need to remove all repeating images except the first one before changing the repeating field to a single field, what should I do before changing the field?
It's not necessary to remove all the repeating images with CRED. Change the repeating field to a single field, then resave the posts to reset the custom field value.
Refer to the screenshots, before I change the repeating field to single, I can see two images saved after I change it to a single field, all images are lost, I expect at least the first image should be kept.
Please advise how I can do. How can I call the function to resave all posts as I can't log in as the customer and view the post one by one and then save?
As Christian is currently unavailable I will be handling this ticket for him.
"I need to remove all repeating images except the first one before changing the repeating field to a single field, what should I do before changing the field?"
What Christian meant in his response to this is that, even though you have changed the field from a Repeatable field to a single field it won't automatically update all the posts to use single fields.
A field data is only set once the post has been updated. This means that all your posts that have the repeatable fields will still show them until the post itself is updated so that the new single image field can be set.
Also as mentioned only the first image will remain after you've done the update.
Thanks for your follow up. As I mentioned, I wouldn't able to do post update one by one, I don't have the users' login, do you have any alternative solution that I can remove all repeated image?