Upload Image into Wordpress Media Library

Heyya, I’m wondering if Gravity Forms has a native way uploading images from a form submission to the Wordpress library yet?

I know Gravity Wiz has a plugin just for this but, I’m just trying to be as lightweight as possible …fewer plugins the better.

Thanks!

Hi @vitamineg, is the form intended to create a post or just a regular entry?

Intended to create a post.

If you use Gravity Forms core Post Creation feature, only the Post Image field type is attached to the media library: https://docs.gravityforms.com/post-image/

If that doesn’t fit your needs and you want to stick to the core functionality, you can use the gform_after_create_post hook that runs just after the post creation, and the media_sideload_image() WP core function https://codex.wordpress.org/Function_Reference/media_sideload_image to attach the files uploaded to the post.

The hook provides you the information that you need to pass to the media_sideload_image() function, the $entry object from where you can grab the values of the fields (the URL to the file) and the $post_id

Or if you have an Elite license, the Advanced Post Creation add-on https://www.gravityforms.com/add-ons/advanced-post-creation/ lets you attach to the media library files uploaded with any standard upload field https://docs.gravityforms.com/creating-a-feed-for-the-advanced-post-creation-add-on/#post-content

1 Like

Thank you @sacom. I think that’s what I need.

1 Like