{"id":731,"date":"2024-05-07T11:42:20","date_gmt":"2024-05-07T11:42:20","guid":{"rendered":"https:\/\/kb.shortpixel.com\/docs\/how-to-exclude-images-from-optimization-in-the-shortpixel-adaptive-images-plugin\/"},"modified":"2025-08-27T08:44:49","modified_gmt":"2025-08-27T08:44:49","password":"","slug":"how-to-exclude-images-from-optimization-in-the-shortpixel-adaptive-images-plugin","status":"publish","type":"docs","link":"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/how-to-exclude-images-from-optimization-in-the-shortpixel-adaptive-images-plugin\/","title":{"rendered":"How to exclude images from optimization in the ShortPixel Adaptive Images plugin"},"content":{"rendered":"<p>In some circumstances, you&#39;ll want to exclude some images from optimization, either due to some incompatibility with another plugin, to be able to <a href=\"https:\/\/help.shortpixel.com\/article\/459-what-does-preload-largest-contentful-paint-image-mean-how-can-i-solve-it\" target=\"_blank\" rel=\"noopener\">preload them<\/a>, or just because you need the original images there.<\/p>\n<p>ShortPixel Adaptive Images offers\u00a0<strong>three ways<\/strong>\u00a0to exclude images, both located on\u00a0<strong>Settings &gt; ShortPixel AI &gt; Exclusions<\/strong>. Please note that you can also use the <a href=\"https:\/\/help.shortpixel.com\/article\/338-how-to-use-the-image-checker-tool\" target=\"_blank\" rel=\"noopener\">Image Checker tool<\/a> to do the same but faster!<\/p>\n<ol>\n<li>Exclusions based on CSS selectors<\/li>\n<li>Exclusions based on URL<\/li>\n<li>Excluded pages<\/li>\n<\/ol>\n<h2>\n<p><img decoding=\"async\"  src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-tZLWkSD2JN.jpg\" style=\"width: 100%; max-width: 100%; \" \/><\/p>\n<\/h2>\n<h2>Excluding CSS selectors<\/h2>\n<p>Excluding a CSS selector not only allows you to exclude several images at once (a CSS selector can target more than one image), but it also lets you exclude an image <strong>only <\/strong>from lazy-loading and\/or resizing.<\/p>\n<ul>\n<li><strong>Don&#39;t lazy-load<\/strong>: the images excluded in this field will not be lazy-loaded, and therefore they will not be properly resized. They will still be optimized, though.<\/li>\n<li><strong>Don&#39;t resize<\/strong>:\u00a0the images excluded in this field will not be properly resized. They will still be lazy-loaded and optimized.<\/li>\n<li><strong>Leave out completely<\/strong>: the images will not be lazy-loaded, properly resized, or optimized.<\/li>\n<\/ul>\n<p>Here&#39;s a table resuming the previous options:<\/p>\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td><strong>Lazy loading<\/strong><\/td>\n<td><strong>Resizing<\/strong><\/td>\n<td><strong>WebP\/AVIF serving<\/strong><\/td>\n<td><strong>Optimization<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>Don&#39;t lazy-load<\/strong><\/td>\n<td> NO<\/td>\n<td> NO<\/td>\n<td> YES<\/td>\n<td> YES<\/td>\n<\/tr>\n<tr>\n<td><strong>Don&#39;t resize<\/strong><\/td>\n<td> YES<\/td>\n<td> NO<\/td>\n<td> YES<\/td>\n<td> YES<\/td>\n<\/tr>\n<tr>\n<td><strong>Leave out completely<\/strong><\/td>\n<td> NO<\/td>\n<td> NO<\/td>\n<td> NO<\/td>\n<td> NO<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>To know what CSS selector you need, you need first to identify the element using the <strong>Inspector arrow<\/strong>\u00a0in the Developer Tools of your browser.<\/p>\n<ol>\n<li>Open your favorite browser and enter your site.<\/li>\n<li>Press F12.<\/li>\n<li>Click on the Inspector arrow.<\/li>\n<li>Click on the image you want to exclude.<\/li>\n<li>\n<p>Inspect the code of the page for that image. In the example image below, you will notice that the image has a class called <code class=\"inline-code\">attachment_thumb_big<\/code>  .<\/p>\n<p><img decoding=\"async\"  src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-BcqndlluEM.png\" style=\"width: 100%; max-width: 100%; \" \/><\/p>\n<p>This image and all images having the same class can be excluded with this CSS selector:\u00a0<\/p>\n<\/li>\n<\/ol>\n<pre>img.attachment_thumb_big\n<\/pre>\n<p>You can also exclude images based on the <strong>id <\/strong>attribute, for example:<\/p>\n<pre>img#id_of_the_image\n<\/pre>\n<p>Or you can exclude inline background images too. For example, if you had a <code class=\"inline-code\">div<\/code>  \u00a0with an inline background image under a\u00a0<code class=\"inline-code\">section<\/code>  , you could use:<\/p>\n<pre>section.example div\n<\/pre>\n<p>You can define multiple exclusions, each on a separate line.<\/p>\n<h3>Performance notes on lazy loading<\/h3>\n<p>Please note that simple rules such as <code class=\"inline-code\">img#id_of_the_image<\/code> are better than complex rules with parent selectors such as <code class=\"inline-code\">section.example div<\/code>  . This is because\u00a0when using a parent element (like a\u00a0<code class=\"inline-code\">div<\/code> that contains the image under it), ShortPixel needs to use JavaScript to determine the exclusions and then decide what to do with the images. Until this JavaScript execution is complete, a placeholder is used instead of the image, which is effectively the same as lazy loading the image. For this reason, some web speed testers will recommend that you do not load the images, even if you have excluded them from lazy loading.<\/p>\n<p>Simple rules allow ShortPixel Adaptive Images to exclude images\u00a0from lazy-loading without any JavaScript processing before, therefore the performance of your website will not be impacted.<\/p>\n<h2>Excluding URLs<\/h2>\n<p>Excluding URLs is not a method as flexible as the previous one, but is easier to implement, as you just need to know the URL. But whatever you exclude here will be completely excluded from optimization.<\/p>\n<p>For the URL exclusion method, you can either use the prefix <code class=\"inline-code\">path:<\/code>  and input a part of the URL,<\/p>\n<pre>path:\/my\/path\/\n\npath:www.someothersite.com\n\npath:logo.jpg\n<\/pre>\n<p>or use a regular expression with the prefix <code class=\"inline-code\">regex:<\/code>  . For example, the next one excludes all GIF images from optimization.<\/p>\n<pre>regex:\/.*.gif$\/i\n<\/pre>\n<p>And the next one\u00a0excludes all the images from subdomains of gravatar.com. Pay attention that it\u00a0is included by default on your settings because many sites use Gravatar and these images cannot be optimized, but if you&#39;re sure your site doesn&#39;t include gravatar URLs, feel free to remove it.<\/p>\n<pre>regex:\/\/\/\/([^\/]*.|)gravatar.com\/\/\n<\/pre>\n<p><\/p>\n<p>The prefix <code class=\"inline-code\">regex:<\/code>  is <strong>not<\/strong> part of the regular expression, but is flagging the next part as a regular expression. For more info about regular expressions, please read <a href=\"https:\/\/www.regular-expressions.info\/\" rel=\"noopener\">this howto<\/a>. You can validate your regular expressions here: <a href=\"https:\/\/regex101.com\/\" rel=\"noopener\">regex101.com<\/a>.<\/p>\n<p>Lastly, you can also exclude only the domain by using a <code class=\"inline-code\">domain:<\/code>  rule, for example <code class=\"inline-code\">domain:cdninstagram.com<\/code>  . This is useful for excluding external domains whose images should remain intact.<\/p>\n<p>You can define multiple exclusions, each on a separate line. <\/p>\n<p>The plugin will silently ignore the malformed exclusions, so make sure to input them correctly.<\/p>\n<h3>Performance notes<\/h3>\n<p>If you input multiple exclusions, please keep them as few as possible, as a huge number of them could impact site performance.<\/p>\n<h2>Excluding pages<\/h2>\n<p>Finally, if you want to exclude entire pages from optimization, you can use this option. All pages in the field will be ignored, and images will not be resized, delayed loading or optimized. The plugin is effectively disabled on these pages.<\/p>\n<p>In Gravity Forms, for example, you can upload files to the forms. Then, when an administrator checks the files from the WordPress backend, those files open in a separate URL that looks like\u00a0<code class=\"inline-code\">https:\/\/www.nu-heat.co.uk\/index.php?gf-download=.....<\/code>  . You\u00a0probably want to exclude this type of page, because no visitor will see it.<\/p>\n<p>You can use the same kind of exclusion methods that you use to exclude URLs:<\/p>\n<ul>\n<li>Use the prefix <code class=\"inline-code\">path:<\/code>  and enter part of the URL,<\/li>\n<li>use a regular expression with the prefix <code class=\"inline-code\">regex:<\/code>  ,<\/li>\n<li>or enter a complete URL.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In some circumstances, you&#39;ll want to exclude some images from optimization, either due to some incompatibility with another plugin, to be able to preload them, or just because you need the original images there. ShortPixel Adaptive Images offers\u00a0three ways\u00a0to exclude images, both located on\u00a0Settings &gt; ShortPixel AI &gt; Exclusions. Please note that you can also [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[35],"glossaries":[],"doc_tag":[],"class_list":["post-731","docs","type-docs","status-publish","hentry","doc_category-shortpixel-adaptive-images"],"blocksy_meta":[],"year_month":"2026-04","word_count":894,"total_views":"2759","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 Adaptive Images","term_url":"https:\/\/kb.shortpixel.com\/knowledge-base\/category\/shortpixel-adaptive-images\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/731","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=731"}],"version-history":[{"count":1,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/731\/revisions"}],"predecessor-version":[{"id":2565,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/731\/revisions\/2565"}],"wp:attachment":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/media?parent=731"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_category?post=731"},{"taxonomy":"glossaries","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/glossaries?post=731"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_tag?post=731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}