Home › Forums › Add-ons › Gallery Field › Upload Image from External URL and add to ACF Gallery › Reply To: Upload Image from External URL and add to ACF Gallery
Your first issue is the starting value
$data['download_screenshots'] = array([
"https://site.com/image.jpg",
"https://site.com/image2.jpg",
"https://site.com/image3.jpg"
]);
The extra square brackets are making a nested array, so what you essentially have here is:
$data['download_screenshots'] = array(
array(
"https://site.com/image.jpg",
"https://site.com/image2.jpg",
"https://site.com/image3.jpg"
)
);
I don’t know what issues this would cause, or for that matter how anything gets imported at all, or this could be the issue with the images being attached to the correct post, I’m not sure. but I think you need to remove the extra []
$data['download_screenshots'] = array(
"https://site.com/image.jpg",
"https://site.com/image2.jpg",
"https://site.com/image3.jpg"
);
The second issue is that when updating a gallery field it expects an array of ID values.
$DownloadScreenShot_Importer = array();
foreach($DownloadScreenShots as $DownloadScreenShot) {
$DownloadScreenShot_Importer[] = media_sideload_image( $DownloadScreenShot, $post_id, NULL, 'id');
}
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.