Hi,
the audio field in the post editor allows one to either upload a file or paste a URL - which is ideal for me.
But not so in the CRED form - it seems one can only upload a file. Is there a way to make it function the same as in the post editor?
I really need my users to have the option. I don't think adding a URL field will work for me because they need to listen to the audio in many places throughout the site...not sure the WP audio player would render an mp3 that is added via a url field.
thank you.
Scott.
Hi Scott,
Thank you for contacting us and I'll be happy to assist.
I'm afraid, the way the audio field is handled in the CRED form, it can't be used to accept a URL of the file directly.
But you can use the following workaround:
1. Instead of a single audio field, you can include two separate fields. First one can be an audio field, for a visitor who'd like to upload an audio file.
The second one can be a regular URL field, for someone who'd like to share a URL to an audio file, which is already uploaded somewhere else.
2. In your view, you can use URL field to generate an audio player, same as the one from the audio file, like this:
[audio src="[types field='audio-url-field' output='raw'][/types]"]
(note: please replace "audio-url-field" with the actual slug of your URL field)
You can read more about WordPress' own audio player shortcode at:
( ref: https://codex.wordpress.org/Audio_Shortcode )
I hope this helps.
regards,
Waqar
Hi Waqar,
very interesting.
I will give it a try.
Thank you!
Scott.
hmm...
doesn't seem to be working out.
If I use the external url method, using the shortcode to generate the audio player - and then later delete the url (lets say the user changes their mind and decides to upload instead) the audio player including the external file it's playing remains and there's no way to delete it - even though the post has been saved with NO external URL in the field. I've cleared all cache and still the same.
any ideas?
thanks!
i guess I can get around it by using a condition
Hi Scott,
Thanks for the update and your understanding is correct.
You can use conditions to display these fields, based on whether they have some values stored in or not.
( ref: https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/ )
For an even neater touch, you can also include a new radio or select type field to let the users choose between upload audio field or the URL field. Based on this selection, you can then hide or show the relevant field.
Let me know if you need any further assistance.
regards,
Waqar
Hi Waqar
Yes - that's what I've done.
Thank you!
Best,
Scott.