Skip Navigation

[Resolved] Create a media attachment with a custom field

This support ticket is created 4 years, 6 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 4 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#1609563

Hi there,

Is there a way to registered a media attachment with a text field in Cred forms? I'm using an external uploader which I would like to save the file url to the media library

Your assistance would be greatly received.

#1610249

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I wonder why you want to use that as Toolset Form itself supports the native media library to upload the image. Please check the following doc:
=> https://toolset.com/documentation/user-guides/front-end-forms/using-the-native-wordpress-media-manager-in-front-end-forms/

However, Toolset form store the full image URL as a custom field value into database. So, if you want to use the text field, you need to make sure that image is uploaded to media library and with the custom field you save the image URL as custom field value to postmeta table.

#1617799

Hi bro,

Appreciate you response. I'm not using the media library because it over complicates the upload process and doesn't seem to have much negotiation in how it's displayed. Also it accepts image files even with just video.

I'm using an external uploader which spits out the temporary URL, trying to figure out how to save that to the media library in some way shape or form.

#1619699

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I got it.

What if you try to add the image filed as Generic field:
=> https://toolset.com/documentation/user-guides/front-end-forms/inserting-generic-fields-into-forms/

The image Generic field will simply allow you to upload image via normal image upload filed. Will this help?

Using Types, you should create a image field using the slug myimg and then with your form you can add the image field using a generic field. will this help?

For example:

[cred_generic_field type='image' field='wpcf-myimg']
{
"required":0,
"persist":1
}
[/cred_generic_field]

If no, you need to use custom script to upload the image and you can use the cred_save_data hook. Please check the following related ticket that might help you - you should adjust your code as per your requirement.
=> https://toolset.com/forums/topic/upload-image-for-post-gallery/#post-25742