Title: Exclude folder or directory inside Uploads
Last modified: July 18, 2020

---

# Exclude folder or directory inside Uploads

 *  Resolved [ateya3d](https://wordpress.org/support/users/ateya3d/)
 * (@ateya3d)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/exclude-folder-or-directory-inside-uploads/)
 * hello
    i use an theme for education courses create a directory inside uploads
   for students assignments
 * and i want to exclude this directory from converting it’s image
 * how can i do this ?
 * and why you not make exclude option available by default ?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Mateusz Gbiorczyk](https://wordpress.org/support/users/mateuszgbiorczyk/)
 * (@mateuszgbiorczyk)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/exclude-folder-or-directory-inside-uploads/#post-13138974)
 * Hi [@ateya3d](https://wordpress.org/support/users/ateya3d/),
 * Thank you for your message.
 * Tell me please, did you read the plugin FAQ before you wrote to me? There is 
   information about the `webpc_attachment_paths` filter that allows you to do what
   you need. Please remember to check all information about the plugin before adding
   a thread to the support forum, because very often the solution is available and
   described.
 * Here is an example of a filter that you can use on your website _(if you have
   already converted images from this directory, delete them manually)_:
 *     ```
       add_filter('webpc_attachment_paths', function($paths)
       {
         /* Part of file path - only use slashes instead of backslashes */
         $excludedPath = 'wp-content/uploads/2020';
         /* Creates pattern that converts one slash from path to one or more slash or backslash chars */
         $regexPattern = str_replace('/', '[\\\\\\\\\/]+', $excludedPath);
   
         foreach ($paths as $index => $path) {
           if (preg_match('/' . $regexPattern . '/', $path)) {
             unset($paths[$index]);
           }
         }
         return $paths;
       }, 10, 1);
       ```
   
 * This filter allows you to check paths before they are passed to WebP conversion,
   before each conversion. Add this code to the `functions.php` file in your theme.
   The given example allows you to exclude all files that are in a given directory_(
   you do not need to specify the entire path, you can specify a part of it)_.
 * Test it please and let me know if this solution has helped you.
 *  Plugin Author [Mateusz Gbiorczyk](https://wordpress.org/support/users/mateuszgbiorczyk/)
 * (@mateuszgbiorczyk)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/exclude-folder-or-directory-inside-uploads/#post-13157600)
 * Hello [@ateya3d](https://wordpress.org/support/users/ateya3d/),
 * How do you do? Did you solve your problem? If so, let us know, otherwise we will
   mark the topic as “resolved” within 7 days.
 * If you have any additional questions, we will be happy to help.
 *  Thread Starter [ateya3d](https://wordpress.org/support/users/ateya3d/)
 * (@ateya3d)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/exclude-folder-or-directory-inside-uploads/#post-13200879)
 * [@mateuszgbiorczyk](https://wordpress.org/support/users/mateuszgbiorczyk/) Thanks
 * Working and solved my problems
 * many thanks

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Exclude folder or directory inside Uploads’ is closed to new replies.

 * ![](https://ps.w.org/webp-converter-for-media/assets/icon-256x256.png?rev=2636288)
 * [Converter for Media - Optimize images | Convert WebP & AVIF](https://wordpress.org/plugins/webp-converter-for-media/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/webp-converter-for-media/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/webp-converter-for-media/)
 * [Active Topics](https://wordpress.org/support/plugin/webp-converter-for-media/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/webp-converter-for-media/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/webp-converter-for-media/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [ateya3d](https://wordpress.org/support/users/ateya3d/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/exclude-folder-or-directory-inside-uploads/#post-13200879)
 * Status: resolved