# Remove Image Tooltips That Repeat the Alt Text

> Removes the title attribute from images in your content when it is the same as the alt text, so screen readers do not read the same description twice.

- Type: PHP
- Runs: Frontend only
- Category: [Accessibility](https://wpide.com/library/category/accessibility/)
- Tags: images, title-attribute, screen-reader
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/a11y-remove-duplicate-image-titles/

## Code

```php
add_filter( 'the_content', function ( $content ) {
    if ( false === stripos( $content, 'title=' ) || ! class_exists( 'WP_HTML_Tag_Processor' ) ) {
        return $content;
    }

    $tags = new WP_HTML_Tag_Processor( $content );

    while ( $tags->next_tag( 'img' ) ) {
        $title = trim( (string) $tags->get_attribute( 'title' ) );

        if ( '' !== $title && strtolower( $title ) === strtolower( trim( (string) $tags->get_attribute( 'alt' ) ) ) ) {
            $tags->remove_attribute( 'title' );
        }
    }

    return $tags->get_updated_html();
}, 20 );
```

## Notes

Titles that add different information are kept.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remove Image Tooltips That Repeat the Alt Text" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
