Home › Forums › General Issues › Save an Image using code, not GUI? › Reply To: Save an Image using code, not GUI?
Saving an image from a URL to an attachment in the media library is not an easy thing to do and there are several plugins that focus on doing just this one thing. Examples https://wordpress.org/plugins/save-import-image-from-url/ and https://wordpress.org/plugins/add-media-from-url/. Here is topic on stack on the subject https://wordpress.stackexchange.com/questions/50123/image-upload-from-url. You might be able to use these as examples.
Also, the ACF image field stores and attachment ID and not a URL, so you would need to have 2 fields, the first to hold the URL and the second to hold the ID. Or if you’re getting the URL from some other source than an ACF image field then you’d need just the image field to store the ID of the imported image.
In either case, you would need to go through the process of importing this image into the media library and then once that is done you get the new attachment ID and set it to the ACF field using
update_field(). But importing images from URLs is way beyond what ACF can do.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.