[Resolved] Image title / Gutenberg

Home Forums Support [Resolved] Image title / Gutenberg

Home Forums Support Image title / Gutenberg

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #1659612

    I’m trying to move from Elementor to Gutenberg with GenerateBlocks but I encountered some problems related to Gutenberg.

    1. My major problem is the image title. WordPress strips the image title and shows on hover the page or post title, which makes absolutely no sense. With the easy fancy box plugin I even had the page/post title below the image. I have absolutely no comprehension, why WordPress does that. With the classic editor and Elementor I used the (outdated) IMG title restore plugin, which solves the problem with some simple lines of code:

    function lcb_img_title_restore( $html, $id ) {
    	$attachment = get_post($id);
        if (strpos($html, "title=")) {
        	return $html;
        else {
    		$mytitle = esc_attr($attachment->post_title);
    		return str_replace('<img', '<img title="' . $mytitle . '" '  , $html);      
    add_filter( 'media_send_to_editor', 'lcb_img_title_restore', 15, 2 );
    function lcb_gallery_title_restore( $content, $id ) {
    	$thumb_title = get_the_title($id);
    	return str_replace('<a', '<a title="' . esc_attr($thumb_title) . '" ', $content);
    add_filter('wp_get_attachment_link', 'lcb_gallery_title_restore', 10, 4);

    I found that I can add the title attribute manually with the code editor, but this is
    ridiculous and impossible to handle. I already insert the title in 3 languages with polylang, so this behaviour of Gutenberg is for me an absolute no go. Can you suggest a code or a plugin to solve this?

    2. Gutenberg has also the great function to strip the hyphen &shy; from the code. When I insert it, it is cancelled during update. This is really bad as long words in German may result in a horrible layout.

    Can you help, please?

    Lead Developer
    Lead Developer

    Hi there,

    These sound like questions that may be better for general WordPress support.

    1. This doesn’t sound right – it should use the title/alt that you define when you add the image to your page. It shouldn’t even be aware of the page/post title.

    2. This sounds like something that should be reported to WordPress – it may be a bug they want to fix.


    Hi Tom,
    (1) the problem with the title was already before Gutenberg. That’s why I’m using the IMG Title restore plugin, but it does not work with Gutenberg. Also in Gutenberg the post/page title is not used but it is possible to add a “title attribute” in the advanced settings of the image block. I think, this is quite crazy. Probably you may integrate an image block into your GenerateBlocks.
    (2) for the wordpress bug reports it needs a graduate degree, but I will try my best.

    Lead Developer
    Lead Developer

    1. Perhaps you have a function or another plugin on your site causing the issue? Does it happen for you on a fresh install with no content/functions/plugins?

    2. It can be difficult, but it sounds necessary in this case, and should be an easy fix 🙂


    1. I have disabled all and used the standard theme twentytwenty with the Health Check & Troubleshooting plugin, but the title attribute is not there. It’s a known problem, I found the workaround here. I’m quite convinced that WordPress / Gutenberg will not change this behaviour.

    2. I found, the bug is already reported and open on Github since June 2020. Somebody proposed a workaround (save draft / update) that works.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.