Remove Titles From Images (Java)

Estimated reading: 3 minutes 161 views

Why Remove Titles From Images?

Removing the title attribute from images helps create a cleaner, more professional website experience. Those yellow hover tooltips often show messy filenames (like IMG_2837.jpg) and can distract from your design. It also prevents screen readers from reading duplicate descriptions, keeps your HTML lighter, and stops gallery or lightbox plugins from pulling the wrong captions. Since Google doesn’t use image titles for SEO anyway, removing them keeps things tidy without affecting rankings. Overall, it gives you more control and ensures your images look polished and intentional across your entire site.

It’s easy to accidentally upload an image without taking a second glance at title. If your media library uses camera names, file numbers, or auto-generated titles, these can appear to visitors.

Prevents accidental exposure of messy filenames

Removing the titles protects you from showing things like:

  • “DSC000034-edit-final-final.jpeg”
  • “Screenshot_20230510”
  • “IMG_2019_05_12_001”

Not exactly the look we want to present!

Avoids duplicate text for screen readers

While alt text is important for accessibility, title attributes can confuse screen readers because some devices read both.
This creates a poor experience for visually impaired users and can cause the same description to be announced twice.

Removing the title attribute avoids this problem and keeps accessibility crisp and clear.

Helps prevent unexpected SEO issues

Google does not use the title attribute on images for ranking — only alt text matters.
However, a badly written or irrelevant title can sometimes cause keyword dilution or give mixed signals.

Removing titles ensures your images rely on the properly-written alt text you actually want Google to see.

Code Snippet

Here’s the exact snippet we use:

document.addEventListener('DOMContentLoaded', function() {
  const images = document.querySelectorAll('img');
  images.forEach(img => {
    img.removeAttribute('title');
  });
});

Where to Add This Code

Here are two easy options:

Option 1: Install WPCode Lite Plugin

This is by far the safest method and is beginner friendly if you’re not used to editing theme files.

  1. Search for WPCode Lite plugin in your website dashboard.
  2. Install the plugin.
  3. Go to Snippets > Add New.
  4. Give your snippet a name like “Remove Titles From Images.”
  5. Paste the code above.
  6. Choose “Run snippet everywhere”.
  7. Choose JAVASCRIPT, not PHP, CSS or any other.
  8. Save and activate.

✅ Done!

Option 2: Functions.php

We don’t advise this option unless you’re a developer or if you feel comfortable editing theme files:

  1. Open your functions.php file .
  2. Paste the snippet at the bottom.
  3. Save and upload if needed.

💡 Tip: Always use a child theme to avoid losing changes when your theme updates.

NOTE: We use WPCode Lite because it’s more flexible than others, there’s no need to upgrade to pro unless you’re a developer, it offers many free snippets, can choose where to run it, won’t publish if the code is wrong so won’t break your site, PHP is included compared to others you have to buy the their pro, and best of all the free version can easily be downloaded from your WordPress Repository.

Leave a Reply

Your email address will not be published. Required fields are marked *

Share this Doc

Remove Titles From Images (Java)

Or copy link

CONTENTS