Support

Account

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.