• Resolved chrislopo

    (@chrislopo)


    I’m trying to import images that were already cropped by another CMS but, if the file name is something like “istockphoto-1193323373-612×612.jpg”, the image is not imported. Any idea on how to fix it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author erolsk8

    (@erolsk8)

    Hey @chrislopo,

    You could use this hook function to include all files:

    /**
     * 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)
    {
        // Custom logic here
        return false;
    }
    add_filter('media_sync_filter_is_scan_object_ignored', 'my_custom_media_sync_additional_file_skip', 10, 3);

    This would of course list all thumbnails generated by WordPress. So if you want to ignore those but not these from the CMS, you would have to write some custom logic using $file_name. For example, this is what’s ignored by the plugin:

    
    // If it contains image size at the end (i.e. -100x100.jpg) or ends with "-scaled" (also WP generated)
    $is_ignored = preg_match('/(-scaled|[_-]\d+x\d+)(?=\.[a-z]{3,4}$)/im', $file_name) == true;
    

    It’s on my to-do list to make UI for this, but I still didn’t get to do it.

    Erol

    Thread Starter chrislopo

    (@chrislopo)

    Thank you a lot! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Images not importing if they are named like NNNxNNN’ is closed to new replies.