@carlosvai
thanks for reporting this issue. We will get this fixed ASAP
Thank you for your excellent work!
I am having an issue where each image upload, for the posts featured image, the image file gets a “.” added in front and its creating the same issue.
@ktchup my advice is to roll back to version 3.17.2 and wait for a fix.
@carlosvai @ktchup
We pushed a fix for this issue in 3.18.1
Great to know! thanks a lot!@shabti
I’ve just tested, but I’m having the same issue.
Let me give some more details to replicate.
The problem happens when you upload images to a gallery field in the backend, save the post, and then upload another image and re-save.
When you go to the media library after that process, you get this
https://ibb.co/xhT5mGt
The image does not have a file name, but not only that, it also makes disappear the file name of the other images already present in the gallery.
I hope that makes sense.
@carlosvai
Thanks for the helpful details. I was able to reproduce the bug and I pushed another fix. Thank you for your help and patience
@shabti thank you for your support with this amazing plug in.
I tested again, is adding “-1” to every image file name.
https://ibb.co/1QbSwSq
Maybe not the first time, but if you save the post and then add a new image, you will see that appended number in all images in the gallery.
Hi @shabti I’m on 3.18.2 and it’s adding a “.” as well as renaming the file completely, resulting in broken images.
I’m rolling back for now, but wanted to give you a heads up.
I identified the pro version to be the issue by the way!
@carlosvai
Is this happening to a file that you hadn’t uploaded already once before?
@juliemclelland
You mean this is happening when you activate the pro version but not when you activate the free version?
@shabti exactly. If I upload a new image in a gallery, when I save the post, all other images get renamed too.
In 3.18.1 the name gets erased and only the .jpg remains.
And in 3.18.2 it prepends the number of the ACF field.
3.17.2 works perfectly.
I have the free version, so it’s not only a pro version issue.
We got it to kind of work using this code (meaning it’s still wonky, but it’s showing images):
add_filter('wp_handle_upload_prefilter', 'custom_upload_filter',20 );
function custom_upload_filter( $file ) {
// Check if the file is an image.
if ( strpos( $file['type'], 'image/' ) === 0 ) {
$random_number = rand(1000, 9999); // Generate a random number between 1000 and 9999
$file['name'] = 'dw-' . $random_number . '-' . $file['name'];
}
return $file;
}
add_filter( 'wp_unique_filename', 'add_dw_and_random_to_filename', 10, 4);
function add_dw_and_random_to_filename($filename, $ext, $dir, $unique_filename_callback) {
$new_filename = 'dw-' . rand(1000, 9999) . '-' . $filename;
return $new_filename;
}
function upload_dir_filter($uploads)
{
$day = date('d');
$uploads['path'] .= '/' . $day;
$uploads['url'] .= '/' . $day;
return $uploads;
}
add_filter('upload_dir', 'upload_dir_filter');
But with this, if Pro is activated, it doesn’t work at all.
Edited to add:
- I took out the above code ^ and deactivated the pro version and it’s working fine on 3.17.2. But since I couldn’t rollback the pro version, it interferes with the 3.17.2 version.