• Resolved van8uren

    (@van8uren)


    I previously had a query, regarding filtering -pdf.jpg files, that was resolved in this topic.

    This lead to me adding the below code to the themes funtions.php

    function my_custom_media_sync_additional_file_skip($is_ignored, $file)
    {
        $is_this_pdf_thumbnail = strpos($file->getFilename(), '-pdf.jpg') !== false;
    
        return $is_ignored || $is_this_pdf_thumbnail;
    }
    add_filter('media_sync_filter_is_scan_object_ignored', 'my_custom_media_sync_additional_file_skip', 10, 3);

    This has been working fine for months, however this snippet seem so be causing an issue with the plugin: https://i.imgur.com/vHOS5hr.png

    If I comment out the snippet the plugin appears to work fine, so I am assuming it is the snippet in functions.php that is causing the issue.

    Is there anything I can change in the snippet to help resolve this issue?

    • This topic was modified 4 years, 4 months ago by van8uren.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author erolsk8

    (@erolsk8)

    Oh sorry @van8uren, I didn’t update that topic to let you know.
    But had to do some optimization, so I can no longer pass $file parameter, but instead, I’m sending 2 separate parameters ($full_path and $file_name).

    So anyway, the new code should look like this:

    
    function my_custom_media_sync_additional_file_skip($is_ignored, $full_path, $file_name)
    {
        $is_this_pdf_thumbnail = strpos($file_name, '-pdf.jpg') !== false;
    
        return $is_ignored || $is_this_pdf_thumbnail;
    }
    add_filter('media_sync_filter_is_scan_object_ignored', 'my_custom_media_sync_additional_file_skip', 10, 3);
    

    Please let me know if that helped.

    Thanks,
    Erol

    Thread Starter van8uren

    (@van8uren)

    @erolsk8 that snippet works fine, many thanks the super fast support!

    Plugin Author erolsk8

    (@erolsk8)

    Caught me at the right moment, after a lunch break ??

    Glad I could help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Critical error caused by filter’ is closed to new replies.