• Resolved ajtatum

    (@ajtatum)


    Hi,

    For some reason, when I tried doing Bulk Upload Images it would stall out and give an error when I turned on WP_Debug.

    The error was:

    PHP Fatal error:  Uncaught TypeError: CF_Images\App\Media::upload_image(): Argument #1 ($metadata) must be of type array, string given, called in /sites/ajtatumdigital.com/html/wp-content/plugins/cf-images/app/class-media.php on line 288 and defined in /sites/ajtatumdigital.com/html/wp-content/plugins/cf-images/app/class-media.php:348
    Stack trace:
    #0 /sites/ajtatumdigital.com/html/wp-content/plugins/cf-images/app/class-media.php(288): CF_Images\App\Media->upload_image()
    #1 /sites/ajtatumdigital.com/html/wp-includes/class-wp-hook.php(308): CF_Images\App\Media->ajax_bulk_process()
    #2 /sites/ajtatumdigital.com/html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
    #3 /sites/ajtatumdigital.com/html/wp-includes/plugin.php(517): WP_Hook->do_action()
    #4 /sites/ajtatumdigital.com/html/wp-admin/admin-ajax.php(188): do_action()
    #5 {main}
      thrown in /sites/ajtatumdigital.com/html/wp-content/plugins/cf-images/app/class-media.php on line 348
    

    Taking a look at line 288 in class-media.php, I saw:

    $this->upload_image( $metadata, $image->post->ID );

    Then, looking at the function upload_images, $metadata is supposed to be an array, but for whatever reason (I tried figuring it out but couldn’t as I couldn’t get the error to tell me what image it was having as issue with) it’s not.

    So, I changed line 288 to be wrapped in a try/catch block as well as check to see if $metadata is an array, and voila!, the bulk upload image worked. However, there were still images that weren’t offloaded and I still had to manually offload them and when I try “Bulk upload images” now it always says 337 images. So, clearly it’s stuck on something, but this code fix uploaded 2k images, which saved me a ton of time.

    Here’s what I changed:

    try {
    	if(is_array($metadata)) {
    		$this->upload_image( $metadata, $image->post->ID );
    	}
    }
    catch(Exception $e)
    {
    	error_log($e->getMessage());
    }

    If this code, or some variation of a fix, cold be implemented in the next release that would be great so I wouldn’t have to remember to apply my “patch”.

Viewing 1 replies (of 1 total)
  • Plugin Author Anton Vanyukov

    (@vanyukov)

    Hi @ajtatum,

    Thank you for reporting this. I have fixed this, and it will be rolled out with the next update. I’ll mark this as resolved for now.

    Best regards,
    Anton

Viewing 1 replies (of 1 total)
  • The topic ‘Possible fix for bulk upload images’ is closed to new replies.