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— theWP_Postobject for the attachment.$attachment->post_titleis 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, 2at 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-imageproperties on a<div>, not as<img>elements at all. There is notitleattribute 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_titlefrom, so the filter will skip them (the$attachmentpassed 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.


