Support

Account

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');
    }