Support a non-standard media path
-
After changing the media date you copy it to a year/month folder (when the uploads_use_yearmonth_folders option is set). But you assume that the file is in the standard oldyear/oldmonth folder, and it’s not always the case when using a plugin which allows custom folders, for example “Media Library Plus”.
What I would suggest is checking if the file exists in the standard directory before trying to copy it.
... $metaolddata = array(); $metaolddata = wp_get_attachment_metadata( $key ); $new_file = $subdir.'/'.wp_basename($metaolddata['file']); $filename = wp_basename($new_file); $upload_old_path = $upload_dir['basedir'].$subdir_post; $copy_file_org = $upload_old_path.'/'.$filename; if ( $new_subdir && file_exists($copy_file_org) ) { ...
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Support a non-standard media path’ is closed to new replies.