Hey @ashmozza89,
Great news, I’m glad you found the solution. But just so you know, this last code will ignore all .webp
files, not just thumbnails. I mean, that’s fine if you don’t need to import any original .webp
file.
First code you sent was checking if file ends with two extensions (e.g. .jpg.webp, .jpeg.webp, etc.). And now I see what was wrong with the original code you sent, that was working in older versions of this plugin, and in order to work with the current version it should be something like this:
/**
* Overwrite Media Sync plugin rules for skipping scanned files or folders.
*
* Should return bool value.
*
* @param boolean $is_ignored Default rules for this file/folder (skipping thumbnails, index.php, hidden files, etc.)
* @param string $full_path Each scanned file/folder absolute path
* @param string $file_name Each scanned file/folder name
* @return boolean
*/
function my_custom_media_sync_additional_file_skip($is_ignored, $full_path, $file_name)
{
// Check if it is optimized .webp file
$is_optimized_webp = preg_match('/.[a-z]{3,4}.webp/i', $file_name) == true;
// Already ignored files or webp
return $is_ignored || $is_optimized_webp;
}
add_filter('media_sync_filter_is_scan_object_ignored', 'my_custom_media_sync_additional_file_skip', 10, 3);
Sorry for the confusion ??
Erol