Change file upload path for ACF custom field
-
Hey there,
Im trying to change the path in which images are uploaded through my ACF custom field. I was able to add a folder within the “/wp-content/uploads” folder and upload to that, but what i really want is to redirect the upload path to a folder outside “uploads”. Is it possible to change the ‘basedir’ and ‘baseurl’ to something like “/wp-content/stuff/uploaded_stuff” for example? Below is the function im currently using to redirect the specific ACF uploader.
add_filter(‘acf/upload_prefilter/name=custom_field_name', 'field_name_upload_prefilter'); function field_name_upload_prefilter($errors) { // in this filter we add a WP filter that alters the upload path add_filter('upload_dir', 'field_name_upload_dir'); return $errors; } // second filter function field_name_upload_dir($uploads) { // here is where we later the path $uploads['path'] = $uploads[‘basedir’].’/unique_upload_folder’; $uploads['url'] = $uploads['baseurl'].'/unique_upload_folder'; $uploads['subdir'] = ''; return $uploads; }
Thanks in advance!
– Charlie
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Change file upload path for ACF custom field’ is closed to new replies.