- Your media files (/image-gallery/) are uploaded to the /wp-content/uploads/folder. (in your control panel)
- If you have access to the server config files, I suggest you also add X-Robots-Tag, so the images wouldn’t be indexed even if hot-linked, e.g.
Stop crawling images using the WordPress dashboard.
- Log into your WordPress dashboard.
- Go to the media library.
- Find the image you want to prevent from being indexed.
- Search for the “Visibility” option in the right sidebar.
- Set the visibility option to hidden or private.
Stop crawling images using robots.txt rules
User-agent: Googlebot-Image
Disallow: /images/ex1.jpg
To exclude multiple images from being indexed on your site, introduce a disallow rule for each image. Alternatively, if the images follow a common pattern, such as sharing a suffix in the filename, employ the * character in the filename. For example:
User-agent: Googlebot-Image
# Repeated ‘disallow’ rules for each image:
Disallow: /images/ex1.jpg
Disallow: /images/ex2.jpg
Disallow: /images/ex3.jpg
# Wildcard character in the filename for
# images that share a common suffix:
Disallow: /images/pictures-*.jpg
Stop crawling images using the server’s configuration file
To include the X-Robots-Tag in a website’s HTTP responses, modify the configuration files of your site’s web server software. For instance, on Apache-based web servers, you can utilize the .htaccess and httpd.conf files. Incorporating an X-Robots tag in HTTP responses offers the advantage of defining crawling rules that apply universally across a site. The use of regular expressions provides a high level of flexibility.
You can use the X-Robots-Tag for non-HTML files, such as image files, where implementing robots meta tags in HTML is not feasible. Here’s an instance of incorporating a noindex X-Robots-Tag rule for image files (.png, .jpeg, .jpg, .gif) throughout an entire site:
Apache:
<Files ~ “\.(png|jpe?g|gif)$”>
Header set X-Robots-Tag “noindex”
</Files>
Nginx:
location ~* \.(png|jpe?g|gif)$ {
add_header X-Robots-Tag “noindex”;
}