How to Disable Automatic Image Title Generation in WordPress

When you upload images to your WordPress media library, WordPress automatically generates a title for each image based on its filename. While this feature can be helpful in some cases, you might prefer to have more control over your image titles.

Fortunately, you can easily disable this automatic image title generation in WordPress by adding a small snippet of code to your theme’s functions.php file. In this tutorial, we’ll walk you through the steps to disable automatic image title generation in WordPress.

WordPress creates image titles automatically on upload to the Media Library

Let’s remove some clutter by disabling the automatic image title generation in WordPress.

Why Automatic Image Titles Are Bad for Your Website

Automatic image titles might seem like a helpful feature, but they can actually have a negative impact on your website. Here are three reasons why you might want to consider disabling automatic image titles in WordPress:

1. Clutter in Your Database

Automatic image title generation adds unnecessary data to your WordPress database, which can lead to database clutter. This can negatively affect your website’s page speed, as a cluttered database can slow down database queries, resulting in slower page loading times.

2. Unwanted Display on Image Hover

Certain WordPress themes (like Divi) and web browsers display image titles as tooltips when users hover their cursor over an image. Automatic image titles, often derived from filenames, can be cryptic and uninformative. This can confuse visitors and create a poor user experience. You could hide image titles on hover in WordPress using custom code or plugins, but why not just remove the source of the problem instead?

3. Time-consuming Manual Work 

It’s possible to delete the auto generated image titles manually after each upload but that slows down your workflow. These extra seconds will add up to minutes that will add up to hours in the long run. By disabling automatic image titles, you can take control and craft meaningful titles that align with your website’s goals and message.

Automatic image titles displayed on hover makes no sense

Automatic image titles adds clutter both in backend and frontend. 

How to Disable Automatic Image Titles in WordPress, Step by Step

To add the code that will disable automatic image title generation, you’ll need to edit your theme’s functions.php file. Make sure that you have an active child theme, otherwise your code will be overwritten next time you update your theme.

Don’t want to use a child theme? No worries, you can add code safely to functions.php using a free plugin like Code Snippets. This way, the code will not be overwritten when you update WordPress and your theme.

Step by step:

  1. Access your WordPress files using an ftp client (for example Filezilla), a file manager at your web hosting control panel or using a plugin like File Manager (the last option is not recommended since you can’t access your files again if something goes wrong).
  2. Go to your child theme folder. It’s typically located in /public_html/wp-content/themes/my-child-theme/ (it might differ depending on your web hosting setup).
  3. Edit the functions.php using a code editor like CotEditor (for Mac) or NotePad++ (for PC).
  4. Add the snippet below file and save your changes:
    // Disable automatic image title generation
    function remove_image_title($attachment_ID) {
        $attachment = get_post($attachment_ID);
        if ($attachment) {
            $attachment->post_title = '';
            wp_update_post($attachment);
        }
    }
    add_action('add_attachment', 'remove_image_title');
    
    function fix_featured_image_text_fields(){
        ?>
        <script>
        jQuery(document).ready(function($){
            setInterval(function () {
                $('.uploading').find('input').attr('readonly', false);
                $('.uploading').find('textarea').attr('readonly', false);
                if ($('.attachments').find('.selected').hasClass('uploading') === false && $('.attachment-details').hasClass('uploading') === true) {
                    var imgsrc=$('.attachments').find('.selected').find('.thumbnail').find('img').attr('src');
                    $('.attachment-details').find('.thumbnail').html('<img src="'+imgsrc+'" draggable="false" alt="">');
                    $('.attachment-details').removeClass('uploading');
                }
                
            }, 10);
        });
        </script>
        <?php
    }
    add_action('admin_footer', 'fix_featured_image_text_fields', 99999);

Now that you’ve added the code to disable automatic image title generation, you can test it by uploading a new image to your media library. When you do, you’ll notice that the Image Title field is blank by default, and WordPress will no longer automatically generate titles for your images. Clear your browser cache and website cache if the changes doesn’t take effect.

Congratulations! You’ve successfully disabled automatic image title generation in WordPress.

Conclusion

By following this simple tutorial, you can take control of your image titles in WordPress. Disabling automatic image title generation allows you to craft custom titles for your images and improving both page speed and user experience.

If you ever want to revert to the default behavior or make further customizations, you can easily remove or modify the code in your functions.php file.

We hope this tutorial has been helpful in enhancing your WordPress media management capabilities. If you have any questions or encounter any issues, let me know in the comments below.

Frequently Asked Questions About Image Titles

Take a deeper dive in the intriguing world of image titles and other image meta texts. 

K
L
What is an image title?

An image title is a short, descriptive text that is associated with an image on a website or within a document. It is typically displayed when a user hovers their cursor over the image. Image titles are primarily used to provide additional context or information about the image and enhance the user experience.

K
L
What's the difference between image title and alt text?

Image titles and alt text serve different purposes. While both are used to provide information about images, they have distinct roles:

Image Title: Image titles are primarily used to offer supplementary information about an image when a user hovers their cursor over it. They are not usually visible until the user interacts with the image, making them a form of tooltip or caption.

Alt Text (Alternative Text): Alt text, on the other hand, serves as a textual alternative for images, providing a description of the image for users who cannot see it, such as those with visual impairments using screen readers. Alt text is an essential accessibility feature and should describe the image's content and function. Alt text is an important factor for usability and SEO.

K
L
When is it appropriate to use image titles?

Image titles are suitable in various situations, including:

  • Enhancing User Experience: Use image titles to provide additional information or context for images to help users understand their relevance or significance.
  • Tool Tips: Image titles can be used for tooltips, offering quick explanations or clarifications when users hover over an image.
  • Descriptive Captions: They can serve as brief, descriptive captions for images, which can be particularly useful in image galleries and sliders.
  • Marketing and Promotion: Image titles can be used to add marketing messages, promotions, or calls to action to images.
  • Educational Content: In educational materials, image titles can be used to add explanations or provide extra details about the content.

K
L
Are image titles important for SEO?

Image titles are not a direct ranking factor for SEO (Search Engine Optimization). Search engines like Google primarily rely on factors like image alt text, image file names, and the content around the image to determine relevance. However, a well-crafted image title can indirectly benefit SEO by providing additional context and improving user experience, which can lead to lower bounce rates and higher engagement, factors that search engines consider when ranking web pages.

That’s all for today!

I hope that you enjoyed this post. Subscribe to DiviMundo on YouTube and join our Facebook group for more crisp content on WordPress and web design.

👉 Related post: How to hide image title text on hover in Divi

👉 Free course: Create a website from scratch with Divi

Related posts

1 Comment

  1. Hello sir, I want to see Google ads when clicked on my Divi website.
    What should be done, please let me know if you have any suggestions.

    Reply

Submit a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Affiliate Disclaimer

All content on DiviMundo is funded by you – our beloved readers. Some of the links are affiliate links. This means that if you click on the link and purchase something, I will receive an affiliate commission. But it will never cost more for you. Thanks for your support!

Victor Duse, founder of DiviMundo