14+ years building on WordPress / Replies in under 5 hours
WordPress 7 min read · Updated July 2026

Adding the Title Tag to Image in Elementor: The Correct Approach

Photo of Ajay Khandal
Ajay Khandal
WordPress Developer
TL;DR

The right way to add image title attributes in Elementor is a WordPress filter hook — not editing Elementor's core plugin file (which gets overwritten on every update). Add an `add_filter('wp_get_attachment_image_attributes', ...)` callback to your child theme's functions.php or a custom mu-plugin in /wp-content/mu-plugins/. The filter reads the Title field from the WordPress Media Library (attachment->post_title) and adds it as a title='' attribute on the rendered <img> tag. This works for the Elementor Image widget and Image Box widget — it does NOT apply to Elementor background images set via CSS.

Elementor’s Image widget doesn’t output a title attribute on its <img> elements by default. The most widely shared fix is to edit image-size.php inside the Elementor plugin folder — which works, but gets overwritten every time Elementor updates. The right fix is a WordPress filter hook that survives updates permanently.

This guide covers the correct approach, where to put the code, how image titles are sourced from the WordPress Media Library, and what this fix doesn’t cover (Elementor background images set via CSS).

alt vs. title: Which One Actually Matters for SEO?

Before the code: understanding which attribute to focus on.

The alt attribute (alt="description") is what Google uses for image indexing. It’s read by screen readers, it’s displayed when an image fails to load, and it’s the primary signal search engines use to understand what an image depicts. Alt text is where you put your SEO effort.

The title attribute (title="tooltip text") on an image creates a browser tooltip on hover. Google has stated that title attributes on images are not a significant ranking signal. Modern screen readers often ignore or announce it redundantly after the alt text. Its practical use in 2026 is limited to tooltip display and very minor accessibility supplementation in specific contexts.

Elementor does output the alt attribute from the image’s Alt Text field in the Media Library — and you can override it per widget in the Image widget’s Content tab. The missing piece is title, and the fix below adds it automatically from the Media Library’s Title field.

Why Editing Core Elementor Files Breaks

The original approach — opening /wp-content/plugins/elementor/includes/controls/groups/image-size.php and adding a title key to the $image_attr array — works until the next Elementor update, at which point the plugin updates overwrite the file and the change disappears. WordPress updates happen automatically for security releases; Elementor updates happen frequently. You’d need to remember to re-apply this edit after every Elementor update, for the lifetime of the site.

Editing files inside /wp-content/plugins/ is never the right approach for persistent customisation. WordPress provides filter hooks precisely so customisations can live outside plugin and theme core files and survive updates.

The Correct Fix: wp_get_attachment_image_attributes Filter

Elementor’s Image widget uses Group_Control_Image_Size::get_attachment_image_html() internally, which calls WordPress core’s wp_get_attachment_image() to render the <img> tag. WordPress applies the wp_get_attachment_image_attributes filter inside that function, giving you a clean injection point for additional HTML attributes — including title.

Add this to your child theme’s functions.php (or a custom mu-plugin — see below):

add_filter( 'wp_get_attachment_image_attributes', function( $attr, $attachment ) {
    if ( ! isset( $attr['title'] ) && ! empty( $attachment->post_title ) ) {
        $attr['title'] = esc_attr( $attachment->post_title );
    }
    return $attr;
}, 10, 2 );

What this does:

  • $attr — the array of HTML attributes being assembled for the <img> tag.
  • $attachment — the WP_Post object for the attachment. $attachment->post_title is the Title field set in the WordPress Media Library.
  • The ! isset( $attr['title'] ) check means the filter only adds the title if one hasn’t already been set — it won’t overwrite a title that Elementor or another plugin has already populated.
  • esc_attr() escapes the value for safe output in an HTML attribute.
  • The 10, 2 at the end tells WordPress to call this callback at priority 10 and pass 2 parameters to it.

This filter fires for every image rendered via wp_get_attachment_image() on the site — not just Elementor images. That covers the Elementor Image widget, Image Box widget, featured images, and any theme or plugin that uses the same WordPress core function.

Where to Put the Code

Option A: Child Theme functions.php (simplest)

Add the filter to the bottom of your child theme’s functions.php. This is fine for site-specific customisations that travel with the theme. If you ever switch themes, the code needs to be moved.

If you’re on a parent theme without a child theme: create a minimal child theme first. Adding the filter directly to a parent theme’s functions.php has the same update-overwrite problem as editing the Elementor plugin file.

Option B: Custom mu-plugin (more portable)

Create a file at /wp-content/mu-plugins/image-title-attr.php:

<?php
/**
 * Add title attribute to WordPress attachment images.
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

add_filter( 'wp_get_attachment_image_attributes', function( $attr, $attachment ) {
    if ( ! isset( $attr['title'] ) && ! empty( $attachment->post_title ) ) {
        $attr['title'] = esc_attr( $attachment->post_title );
    }
    return $attr;
}, 10, 2 );

Must-use plugins (mu-plugins) load automatically before regular plugins, don’t appear in the Plugins list to be accidentally deactivated, and survive theme changes. For a simple site-wide modification like this, an mu-plugin is the cleanest approach. For the full plugin structure pattern (headers, ABSPATH guard, activation hooks), see how to create a WordPress plugin from scratch.

Setting Image Titles in the WordPress Media Library

The filter reads $attachment->post_title — the Title field for the attachment in the Media Library. If your images have blank titles, the filter’s ! empty( $attachment->post_title ) check prevents outputting an empty title="" attribute.

To set or check an image’s title: Media → Library → click the image → the Title field is in the right panel (Attachment Details). This is separate from the Alt Text field, which appears below it.

When you upload an image, WordPress automatically sets its Title to the filename (with hyphens replaced by spaces and the extension stripped). For example, product-hero-shot.jpg gets a default title of “product hero shot”. You should update these to meaningful titles — the filter outputs whatever the Title field contains.

Verifying the Fix

After adding the filter code, open a page with an Elementor Image widget in your browser, right-click the image → Inspect Element (or press F12 → Elements tab). You should see the <img> tag now includes a title="..." attribute matching the Title field in the Media Library:

<img
  width="1024"
  height="683"
  src="https://example.com/wp-content/uploads/image.jpg"
  class="attachment-full size-full"
  alt="Product description"
  title="Product hero shot"
  decoding="async"
  loading="lazy"
/>

If the title attribute is absent, check that: (a) the code was added to the correct file and saved, (b) any server-side or object cache was cleared after saving, and (c) the image in question has a non-empty Title in the Media Library.

Before making any PHP changes to a production site, test them on a staging environment first — a syntax error in functions.php can white-screen the site. See how to set up a WordPress staging environment for the safe workflow.

What This Fix Doesn’t Cover

The wp_get_attachment_image_attributes filter only applies when wp_get_attachment_image() is called. Two Elementor patterns don’t use this path:

  • Elementor background images (set via the Style tab → Background → Image) — these render as CSS background-image properties on a <div>, not as <img> elements at all. There is no title attribute equivalent for CSS background images; they also don’t carry alt text and should be purely decorative.
  • External images (Elementor Image widget with an external URL rather than a Media Library attachment) — there’s no WordPress attachment object to read post_title from, so the filter will skip them (the $attachment passed may not be a valid attachment object).

For both cases, if a tooltip or accessible label is genuinely needed, a custom JavaScript approach (adding title attributes via a DOM mutation or Elementor’s Custom HTML widget) is the only option — but reconsider whether a title attribute is the right tool for what you’re trying to achieve.

For broader Elementor development context — including how Elementor stores widget data and how this affects theme switching — see the Elementor vs Divi vs WPBakery comparison. For the full wp_get_attachment_image() function and its parameters, see wp_get_attachment_image() explained. And for a direct comparison of Elementor against the block editor approach, see Elementor vs Gutenberg in 2025.

Frequently asked questions

Minimally. Google has stated that the title attribute on images is not a significant ranking signal. The alt attribute is what Google uses for image indexing and should receive your SEO focus — it's also used by screen readers and displayed when an image fails to load. The title attribute creates a browser tooltip on hover and has some supplementary accessibility value, but it's not a meaningful SEO lever. If your images are missing alt text, fix that before worrying about title attributes.

Elementor's Image widget focuses on the attributes that have real impact: alt text (mapped from the Media Library's Alt Text field), class, width, height, and loading strategy. The title attribute was excluded from the default output because it's not required for accessibility or SEO. The WordPress core function that Elementor uses (wp_get_attachment_image) also doesn't include title in its default attribute set — it has to be added via the wp_get_attachment_image_attributes filter.

Use the wp_get_attachment_image_attributes WordPress filter hook. Add this to your child theme's functions.php or a custom mu-plugin in /wp-content/mu-plugins/: add_filter('wp_get_attachment_image_attributes', function($attr, $attachment) { if (!isset($attr['title']) && !empty($attachment->post_title)) { $attr['title'] = esc_attr($attachment->post_title); } return $attr; }, 10, 2); This reads the Title field from the WordPress Media Library and outputs it as a title attribute. It survives Elementor updates because it lives outside the plugin folder.

In the WordPress Media Library: Media → Library → click the image → Title field in the Attachment Details panel on the right. This is the 'Title' field, which is separate from the 'Alt Text' field below it. WordPress auto-populates the Title from the filename when you upload an image (e.g., 'product-hero.jpg' becomes 'product hero'). The wp_get_attachment_image_attributes filter reads this Title field via the attachment's post_title property. If the Title field is blank, the filter's empty() check prevents outputting a blank title attribute.

No. Elementor background images (set via Style → Background → Image) are rendered as CSS background-image properties on a

element — not as tags. The wp_get_attachment_image_attributes filter only fires when wp_get_attachment_image() is called, which is the path used by Elementor's Image widget and Image Box widget. CSS background images do not support title or alt attributes — they should be purely decorative with no text alternative needed.

Technically yes, but it has the same update-overwrite problem as editing Elementor's plugin files — when the parent theme updates, functions.php gets overwritten and your code is gone. The correct options are: (1) a child theme's functions.php — code survives parent theme updates, (2) a custom mu-plugin in /wp-content/mu-plugins/ — survives both theme and plugin updates, or (3) a custom plugin in /wp-content/plugins/ — gives you full version control and activation/deactivation control. For a single-site modification like this, an mu-plugin is the simplest permanent solution.

Photo of Ajay Khandal

Written by Ajay Khandal

I'm a freelance WordPress developer with 14+ years of experience building, fixing, and speeding up sites for businesses, agencies, and store owners across the US, UK, Europe, and Australia. I specialize in custom themes, WooCommerce, and performance — the kind of work that shows up as faster load times and fewer support tickets. No account managers, no outsourced tickets — you work directly with me, with replies typically inside 5 hours.

Work with me →