Skip Navigation

[Resolved] Potential issue if changing repeating image field to single

This support ticket is created 5 years, 12 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 9 replies, has 3 voices.

Last updated by Shane 5 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1230535

Dear Sir/Madam,

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?

Best regards,

Kelvin.

#1230698

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.

#1231015

Dear Christian Cox,

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?

Best regards,

Kelvin.

#1231074

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.

#1231656

Dear Christian Cox,

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?

Best regards,

Kelvin.

#1231856

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.

#1231921
Screenshot 2019-04-17 at 7.45.56 AM.png
Screenshot 2019-04-17 at 7.45.40 AM.png
Screenshot 2019-04-17 at 7.45.01 AM.png

Dear Christian Cox,

Sorry, I can't get the meaning of your answer especially the statement "Then it should appear as expected in the Edit Post Form.".

Below please find the coding in my Post Form

  <div class="form-group" style="color: red;">我們已更新了圖片上載功能,只顯示首張封面圖片及同時多張副圖。</div>
	<div class="form-group">
		<label>封面圖片</label>
		[cred_field field='photo' value='' urlparam='' output='bootstrap']
	</div>

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?

Best regards,

Kelvin.

#1232358

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kelvin,

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,
Shane

#1233572

Dear Shane,

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?

Best regards,

Kelvin.

#1234575

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kelvin,

All the images are actually stored in the media gallery so you should be able to delete them from there.

The only other way is to use some custom code to get this done for you.

Thanks,
Shane