Replies: 0
How do I save images to custom directory based on postname or posttitle. I have scraped a list of product names and image urls, i want to save all images to /uploads/{postname}/{image_1.jpg} eg: /uploads/MSIRX580/image_1.jpg
The default method of saving 30k images on a single directory is not ideal or organised for me.
I tried this code but WP All Import doesn’t create or save in any directory.
function add_date_to_upload_dir( $param ) {
$the_post = $_REQUEST[‘post_id’];
$dir = ‘/’ . $the_post->post_name . ‘/’ ;
$param[‘path’] = $param[‘path’] . $dir;
$param[‘url’] = $param[‘url’] . $dir;
return $param;
}
add_filter( ‘upload_dir’, ‘add_date_to_upload_dir’ );