• Hello,
    I created a CPT, then with ACF I setted up a field to upload files. Files uploaded for this CPT, where uploaded in a custom folder.
    Now, this is the problem. The file is always uploaded correctly, but if the custom folder wasn’t previously checked by Media Library Folders, I get an error after upload.

    Upload after Media Library Folders has checked folders:

    New folder created on the fly so not yet checked by Media Library Folders:

    Even if I get this error, the file is correctly uploaded and if I close the Media Library popup and reopen it, I can select the file and attach it to the post.

    To change the upload folder I use “upload_dir” hook the function is this one:

    
    function change_upload_dir( $param ) {
      $request = array_change_key_case( $_REQUEST, CASE_LOWER );
    
      if ( isset($request['post_id']) )
        $post_id = $request['post_id'];
      else
        $post_id = $request['post'];
    
      $brand = get_post( get_field('relations', $post_id )['brand'][0] )->post_name;
      $path = '/risorse/' . $brand;
      $param['path'] = $param['basedir'] . $path;
      $param['url'] = $param['baseurl'] . $path;
      $param['subdir'] = $path;
    
      return $param;
    }
    

    Is there away to force check folders with a hook in your plugin or something similar?

    I hope I explained enough my problem… ??

    Thank you ??

Viewing 1 replies (of 1 total)
  • Plugin Author AlanP57

    (@alanp57)

    I have not tested this, but you can try adding this code to your function:

    global $maxgalleria_media_library;
    
    $maxgalleria_media_library->admin_check_for_new_folders(true);
Viewing 1 replies (of 1 total)
  • The topic ‘Conflict with ACF (File field) and upload_dir action’ is closed to new replies.