{"id":787,"date":"2024-05-07T11:43:20","date_gmt":"2024-05-07T11:43:20","guid":{"rendered":"https:\/\/kb.shortpixel.com\/docs\/how-to-exclude-images-from-being-optimized\/"},"modified":"2025-08-27T08:43:15","modified_gmt":"2025-08-27T08:43:15","password":"","slug":"how-to-exclude-images-from-being-optimized","status":"publish","type":"docs","link":"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/how-to-exclude-images-from-being-optimized\/","title":{"rendered":"How to exclude images from being optimized?"},"content":{"rendered":"\n<p>You can exclude files or folders from optimization that match our accepted patterns by using the <strong>Exclude Patterns<\/strong> feature in the plugin settings (<em>Settings > ShortPixel > Exclusions<\/em>).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"407\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092315-1024x407.jpg\" alt=\"\" class=\"wp-image-1649\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092315-1024x407.jpg 1024w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092315-300x119.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092315-768x305.jpg 768w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092315-360x143.jpg 360w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092315.jpg 1229w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>By patterns, we mean rules that our plugin understands. Don&#8217;t worry\u2014ShortPixel Image Optimizer (SPIO) has a user-friendly interface that allows you to easily create your own exclusion patterns.<\/p>\n\n\n\n<p><b>There are three types of exclusions<\/b>: based on the file name (files), based on the file path (folders) or based on the file size. Each exclusion type can be applied to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>All versions of each image. This includes all thumbnails, the <code class=\"inline-code\">-scaled<\/code> version and the original full-size image.<\/li>\n\n\n\n<li>Only the thumbnails. In this case, the original and the <code class=\"inline-code\">-scaled<\/code> version are <u>not<\/u> excluded.<\/li>\n\n\n\n<li>Only Custom Media images. In this case the items from the Media Library are <u>not<\/u> excluded.<\/li>\n\n\n\n<li>Only a selection of thumbnails of your choice.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">How to exclude files<\/h2>\n\n\n\n<p>Choose the <b>Image Name<\/b> exclusion type and enter part or all of the file name in the <strong>Value<\/strong> field.<\/p>\n\n\n\n<p>For example, to exclude the &#8220;logo.jpg&#8221; image from optimization, enter <code>logo.jpg<\/code> in the <strong>Value<\/strong> field. Note that the value you enter is <strong>case-sensitive<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"543\" height=\"313\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092621.jpg\" alt=\"\" class=\"wp-image-1650\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092621.jpg 543w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092621-300x173.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_092621-360x208.jpg 360w\" sizes=\"(max-width: 543px) 100vw, 543px\" \/><\/figure>\n\n\n\n<p>A small change to the pattern can result in a broader selection. For example, entering <code>logo<\/code> will exclude all images (PNG, JPEG, GIF) that contain &#8220;logo&#8221; in their name, such as &#8220;nicelogo.jpg&#8221;, &#8220;alllogos.png&#8221;, or &#8220;logo.gif&#8221;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to exclude folders<\/h2>\n\n\n\n<p>Choose the <b>Image Path<\/b> exclusion type and enter part of the path you want to exclude in the <strong>Value<\/strong> field. Note that the value you enter is <strong>case-sensitive<\/strong>.<\/p>\n\n\n\n<p>For example, entering <code>2022<\/code> in the <strong>Value<\/strong> field will exclude all images uploaded in 2022. This is because a default WordPress installation generates URLs like &#8220;https:\/\/mydomain.com\/wp-content\/uploads\/2022\/MM\/myimage.jpg&#8221; (where &#8220;mydomain.com&#8221; is your domain, &#8220;2022&#8221; is the upload year, &#8220;MM&#8221; is the upload month, and &#8220;myimage.jpg&#8221; is the filename).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"532\" height=\"328\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_093517.jpg\" alt=\"\" class=\"wp-image-1651\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_093517.jpg 532w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_093517-300x185.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_093517-360x222.jpg 360w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/figure>\n\n\n\n<p>Note that, in the previous example, images with &#8220;2022&#8221; in the file name will also be excluded since it is part of the path. To exclude only images uploaded in 2022, enter <code>\/2022\/<\/code> instead.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to exclude file sizes<\/h2>\n\n\n\n<p>Choose the <strong>Image Size<\/strong> exclusion type if you&#8217;d like to exclude all images and thumbnails within the specified size range. You can also specify an exact size by enabling the <strong>Exact sizes<\/strong> option.<\/p>\n\n\n\n<p>The following example excludes all images smaller than 1024px wide from optimization.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"595\" height=\"414\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_093719.jpg\" alt=\"\" class=\"wp-image-1652\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_093719.jpg 595w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_093719-300x209.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250203_093719-360x250.jpg 360w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">The power of regular expressions<\/h2>\n\n\n\n<p>Regular expressions can help you set more advanced exclude patterns. These can be used with the <strong>Image Name<\/strong> or <strong>Image Path<\/strong> types. A regular expression must be enclosed between slashes (<code>\/ \/<\/code>), and special characters should be escaped by adding a backslash in front of them. Here are a couple of examples that demonstrate their power:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>All images from 2016: <code class=\"inline-code\">\/\\\/2016\\\/\/<\/code><\/li>\n\n\n\n<li>All images containing the word &#8220;flower&#8221; in the filename and ignoring case sensitivity (eg: will exclude files named &#8220;flower&#8221;, &#8220;Flower&#8221;, &#8220;floWER&#8221;, and so on): <code class=\"inline-code\">\/(?i)flower\/<\/code><\/li>\n\n\n\n<li>All GIF images: <code class=\"inline-code\">\/\\.gif$\/<\/code><\/li>\n\n\n\n<li>All images that are not GIF files: <code class=\"inline-code\">\/.*\\.(?!gif$)[^.]+$\/i<\/code><\/li>\n\n\n\n<li>All PNG images that have a numeric prefix: <code class=\"inline-code\">\/[0-9]+[^\/]*\\.(PNG|png)\/<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Regular Expression resources<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/regular-expression-language-quick-reference\" rel=\"noopener\">Microsoft docs<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Regular_expression\" rel=\"noopener\">Wikipedia<\/a><\/li>\n\n\n\n<li><a href=\"http:\/\/www.rexegg.com\/regex-quickstart.html\" rel=\"noopener\">Regex Cheat Sheet<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>You can exclude files or folders from optimization that match our accepted patterns by using the Exclude Patterns feature in the plugin settings (Settings > ShortPixel > Exclusions). By patterns, we mean rules that our plugin understands. Don&#8217;t worry\u2014ShortPixel Image Optimizer (SPIO) has a user-friendly interface that allows you to easily create your own exclusion [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[37],"glossaries":[],"doc_tag":[],"class_list":["post-787","docs","type-docs","status-publish","hentry","doc_category-shortpixel-image-optimizer"],"blocksy_meta":[],"year_month":"2026-04","word_count":514,"total_views":"1313","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"admin","author_nicename":"admin_mdli53m5","author_url":"https:\/\/kb.shortpixel.com\/author\/admin_mdli53m5\/"},"doc_category_info":[{"term_name":"ShortPixel Image Optimizer","term_url":"https:\/\/kb.shortpixel.com\/knowledge-base\/category\/shortpixel-image-optimizer\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/comments?post=787"}],"version-history":[{"count":2,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/787\/revisions"}],"predecessor-version":[{"id":1653,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/787\/revisions\/1653"}],"wp:attachment":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/media?parent=787"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_category?post=787"},{"taxonomy":"glossaries","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/glossaries?post=787"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_tag?post=787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}