5 ways to find out where an image is used on a WordPress site

Five methods to find where a specific image is used on a WordPress site – not only in post and page contents, but almost anywhere.

As a WordPress site owner or manager, you may occasionally need to locate whether or where specific images are being used on your site. This tutorial will provide you with various options on how to find the exact locations of your images on your WordPress site.

There are several situations in which I personally need to find where an image is used:

  1. Remove orphaned images: Unused images take up space. Not just server space – especially since WordPress stores the same image in multiple sizes – but also space in the media library. I like to keep my media library clean to find pictures from the past faster. See How to find unused images in WordPress.
  2. Replace outdated images: Sometimes, a new version of Image Source Control contains updated strings or new elements in the interface. In these cases, there are always one or two screenshots in the manual that need updating. I am using some screenshots in multiple places, so I need a way to identify these.
  3. Improve existing images / SEO: Sometimes, I like to update certain image descriptions or alt texts for SEO purposes or check if the caption entered in the media library is really displayed. I could go through each post manually or work on specific images or image types in bulk, for which I would need to find them.

In this tutorial, I will discuss various methods to find where an image is used on a WordPress site. I have tried all of them and will highlight my preferred choice in the final conclusion.

Tested methods:

Find used Images in the WordPress Media Library

When you upload an image directly to a page or post using the block or classic editor, WordPress automatically associates the image with that specific content. The “Uploaded to” section of the image details in the Media Library displays the title of that associated page or post, along with a clickable link that takes you directly to the edit screen.

List of image information in the Media Library, including “Uploaded To”
List of image information in the Media Library, including Uploaded To. Click for more context.

If an image has not been attached to any content, the “Uploaded to” section will display “Unattached.”

Access the Media Library

  1. Log in to your WordPress dashboard.
  2. Locate the “Media” option in the left sidebar menu and click on “Library.”

Search for the Image

  1. In the Media Library, use the search bar at the top right to find the image you want to locate.
  2. Click on the image thumbnail to open the Attachment Details window.

Check the “Uploaded to” Section

  1. In the Attachment Details window, find the “Uploaded to” section on the right-hand side.
  2. This section will display the page’s name or post where the image is used, along with a clickable link. The “Uploaded to” section is missing if the image was not uploaded through a post or page.

Bonus tip: You can also check the “Uploaded to” column when switching the Media Library to the list view as shown in the next screenshot.

Image Library in List view with the Uploaded To column highlighted.
The Media Library in List view with the “Uploaded To” column visible.

Using Image Source Control

Image Source Control creates an index of images within certain posts and pages. Compared to the “Uploaded to” section in the Media Library, it will list more than one post or page if the image is used multiple times.

A list of images with an unknown position on a WordPress site.
Image Source Control shows a list of images with an unknown position. In this example, the authors eventually didn’t include them in their posts, or the posts never went live.

The ISC index also contains images that are outside of the typical content, e.g., in the sidebar or header, or when they are added dynamically through a block or shortcode.

A list of Images and Posts in which they are displayed
List of known image-post relations in the Image Source Control options.

Safely remove unused images

Image Source Control also comes with the ”Unused Images“ overview, which you can use to check and safely delete unused images in bulk.

Open the Image-Post Index

  1. Log in to your WordPress dashboard.
  2. Locate the “Media” option in the left sidebar menu and click on “Image Sources.”
  3. Click on the “list image-post relations” button in the “Debug” section.
  4. Look for the image title in the table and find posts using the image in the right column.

Click on the post title to go to the appropriate edit page. It is best to check the frontend view of the post to see where it is actually used and then identify where it can be changed.

Did you know? Image Source Control can also generate a list of images on a site, including their authors on a dedicated page. Check out the list of all features.

Find used Images in the Database

If you have access to your WordPress site’s database, you can search image usages with SQL queries or the search provided by the database tool.

This method allows you to find all instances of an image, regardless of size variations, throughout your site’s content and options.

The first submethod is helpful if you have some knowledge of SQL to make adjustments, e.g., when your database prefix differs from the default. The second method needs knowledge about the structure of WordPress databases.

Exercise caution when working with your database to avoid unintentional data loss or corruption.

Identify the Image Filename

  1. Navigate to the Media Library in your WordPress backend and locate the image you want to search for.
  2. Make a note of the image filename (without the dimensions) and the file extension (e.g., .jpg, .png, .gif).

Example: If the image file is my-cute-dog.jpg, the filename is “my-cute-dog,” and the extension is “.jpg.”

Access Your WordPress Database

  1. Log in to your web hosting control panel (e.g., cPanel).
  2. Locate the “Databases” section and click on “phpMyAdmin” or any other database management tool provided by your hosting provider.
  3. In phpMyAdmin or the chosen tool, select your WordPress database from the left sidebar.

Search Images in Content

The following queries will help you to find specific images in the content of posts, pages, and any other post types. Jump to the next section if there is a chance of an image being used in other sections, like options or metadata.

  1. In your database management tool, click the “SQL” tab or locate the SQL query editor.
  2. Enter the following query, replacing wp_posts with the actual name of your posts table (if it uses a different prefix), and IMAGE_FILENAME with the appropriate information from step 1:
SELECT * FROM wp_posts
AND post_type != 'revision';Code language: JavaScript (javascript)

Example: If your image filename is “my-cute-dog,” your query should look like this:

SELECT * FROM wp_posts
WHERE post_content LIKE '%my-cute-dog%'
AND post_type != 'revision';Code language: JavaScript (javascript)
  1. Execute the query. The search results will display all posts and pages where the image is used, regardless of its dimensions.
An SQL query in phpMyAdmin that finds an image in post content.
An SQL query in phpMyAdmin finds an image in the content of this very post.

As you might have seen, my query excludes “revisions.” These are previous versions of your post that WordPress creates automatically. They allow you to see the history of a post over time and revert changes. There are normally a lot of them stored in the database, which would create noise in the results.

Usually, the images appear in the post_content field. Use the ID or the title from the post_title field to search for the post or page in your WordPress backend.

Use regular expressions

The SQL query above has a caveat with short filenames.

Imagine I just used “dog.” Depending on my site, there could be a lot of results from posts containing the word “dog” but not the image I was looking for.

To find fewer unique image files, we need to include the file extension in the search. At the same time, we need to consider that WordPress uses variations of image files, e.g., dog-1024x400.jpg.

An appropriate SQL query for our example would be the following:

SELECT * FROM wp_posts
WHERE post_content REGEXP 'dog[^[:space:]]*\\.jpg' 
AND post_type != 'revision';Code language: JavaScript (javascript)

The query finds image files with the original filename at the beginning and any non-space characters between the extension.

Search Images Everywhere

Sometimes, an image is not only part of the content but also used in options or metadata. It might then be useful to widen the search to anywhere in the database. While this method does not include using SQL, identifying the results needs more knowledge about WordPress’ database structure than looking for images in the content.

This can be done with the general search form in phpMyAdmin.

  1. Open phpMyAdmin.
  2. Select the database you want to search in.
  3. Navigate to the “Search” tab in the top navigation.
  4. Fill in the image filename and file extension in the search field under “Search in database.” Separate them using space.
  5. Select “all of the words” in the “Find” section.
  6. Select the relevant tables in the “Inside tables” section. If you have many or very large tables, it might be useful to select individual ones.
  7. Click “Go” to run the search.

If you are an advanced user, you could also use a regular expression. Taking our example dog[^[:space:]]*\\.jpg from above, you need to remove the double backslash for the search to work, i.e., dog[^[:space:]]*\.jpg.

Database search for image with regular expression
A full-database search for an image using a regular expression.

You will probably see more results than just searching through the content. This is because image information themself are stored in the database, and revisions are not excluded either.

So for a better result, I would suggest running the SQL query to find images in the content first and then exclude the wp_posts table from the search. You might also exclude wp_postmeta limiting the results solely to non-content elements.

Identifying relevant results might take some knowledge about where and how WordPress, or certain plugins, store information in the database. E.g., options are often stored in a serialized array, which might need some experience or an external tool to interpret.

Using the Post Search in the WordPress Backend

Another method to find used images on your WordPress site is the built-in post search in the backend. This method allows you to search for image filenames within your site’s content, which can help you locate where the image is being used.

Identify the Image Filename

  1. Navigate to your Media Library and locate the image you want to search for.
  2. Make a note of the image filename without the extension.

Note: Alt texts or captions added to the Media Library might work, too, as search terms. When an image is added to the content, WordPress uses the alt text from the Media Library in the post content as well. However, from this point, changes to the alt text in your Media Library would not change the alt text in your post and vice versa. So the results of such a search are not reliable.

Use the Post Search Functionality

  1. In your WordPress dashboard, click on “Posts” in the left sidebar menu.
  2. Locate the search bar at the top right corner of the “Posts” screen.
  3. Enter the image filename from Step 1 into the search bar and click “Search Posts.”
  4. The search results will display all posts that contain the entered image filename.
  5. Click on each post in the search results to open the editor and verify the image usage.
The post overview page in a WordPress backend filtered by an image filename that was used in the listed post.
The post search is filtered by the filename from an image in this post.

To ensure that you find all instances of the image on your site, repeat the search for pages by clicking on “Pages” in the left sidebar menu of your WordPress dashboard and using the search functionality.

Using Google Image Search

Google Image Search is a powerful tool that can help you locate instances of an image not only across the internet but also just on your own site. By using Google’s reverse image search feature, you can find where an image is used by searching for the image URL or by uploading the image itself.

Locate the Image URL or Download the Image

  1. Navigate to your WordPress Media Library and locate the image you want to search for.
  2. Either copy the image URL from the Attachment Details window or download the image to your computer.

Do a Reverse Image Search

Google Images search by image.
  1. Open your web browser and visit the Google Images homepage.
  2. Click on the camera icon in the search bar to access the reverse image search feature.
  3. You have two options in the Google Images reverse search window: a. Paste the image URL into the “Paste image URL” field and click “Search by image.” b. Click “Upload an image” and choose the downloaded image from your computer.
  4. Google will perform a reverse image search and display the search results.

Filter the Search Results for Your Site

If the image is used on more than just your website, you can narrow it down by entering site:YOURSITE into the search form. Replace “YOURSITE” with the homepage URL of your website.

Search for images on a specific website in Google Images.

Google will now display search results for instances of the image on your site. I have tried this with various images and found instances where Google missed a URL. Since Google index and their Image Search are a black box, it might only give you a quick overview, but you should not rely on it.


In this tutorial, I tested a few methods for finding where an image is used on your WordPress site:

  • “Uploaded to” information in the Media Library
  • Using Image Source Control
  • Search the database directly
  • Post Search in the Backend
  • Google Images reverse search

Each method has its own benefits and drawbacks, so choose the one that best fits your needs and technical expertise.

I recommend Image Source Control for teams and less technical editors since it indexes images on multiple posts and even outside of the content. When I am not sure if an image might be used outside of the content, I use the database search. It takes significantly more time, so I only do it when there is a reason to think an image is used in unusual spots.

By regularly monitoring and managing your site’s images, you can maintain a clean media library, improve site performance, optimize SEO, and ensure that your content remains up-to-date and relevant.

If cleaning up the media library is your main goal, check out Find unused images in WordPress.

Portrait of Thomas Maier, founder and CEO of Image Source Control

Questions? Feedback? How can I help?

Reach out directly via the contact form.