Hi there,
I have used form_options to create form for custom widget in page builder using so widget bundle. Now I am able to get all the other field data like text, textarea, etc.
But I am not getting media URL that I have uploaded in MEDIA form field.
Can you please give me code to get my image that I have uploaded from media File upload?
Awaiting to hear from you.
Hi Makwana
Thanks for reaching out.
I had a quick chat with Braam, one of our developers. He let me know that the media field returns and ID, it doesn’t return a URL. You’ll need to use a function like:
https://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
to resolve the URL.
Hope that helps a little. We unfortunately don’t have an example on GitHub, we just checked.
A quick addition. There are a few functions like the above. You can use any of them:
https://codex.wordpress.org/Function_Reference/wp_get_attachment_url
https://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata
https://codex.wordpress.org/Function_Reference/wp_get_attachment_image
https://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
https://codex.wordpress.org/Function_Reference/wp_get_attachment_link
https://codex.wordpress.org/Function_Reference/wp_get_attachment_thumb_url