Images Assigned Wrong TITLE Attribute Value In HTML

#360994
  • Resolved SoonerKnives
    Rank Math free

    When turning on “Add missing TITLE attributes” in General Settings -> Images, image TITLE attributes are all populated with the same value from one product when using %title% as HTML is rendered (even when there is already a populated TITLE attribute for the image), regardless of actual image/post values.

    Goal: To populate empty TITLE attributes for images with the Product Title.

Viewing 6 replies - 16 through 21 (of 21 total)
  • Hello,

    Even the images on the homepage that are under the “Featured For You” section are added inside a block called kadence/rowlayout which correlates with what we reported before that this feature doesn’t work properly inside those blocks.

    Any images that are outside the blocks, be it layout blocks or any other would work as expected and display the missing title tag according to your specifications.

    Don’t hesitate to get in touch if you have any other questions.

    Okay, I am not getting anywhere when this is answered by a Developer! You are not reading the issue, and my constant repeats of the problem.

    I will try once more, then I will think about stopping dealing with Kadence – if their support is going to be so asinine. (I wonder if it is because I am a free customer – doesn’t speak well for the product!)

    PLEASE READ:
    —————–
    The setting under “RankMath – General Settings – Images – Add missing TITLE attributes” is turned on. RankMath is replacing the TITLE attribute (even on images that have an existing TITLE attribute) with one product’s title – NOT THE PRODUCT TITLE FOR THAT SPECIFIC PRODUCT/POST, but a global value. The other feature on that settings page, “Add missing ALT attributes” works fine, picking up the correct product/post title, using the same “%title%”. You can see the error in all of the pics on the homepage: https://staging4.soonerknives.com/, except for the background pic in the “Why Buy From Us” section.

    All the remaining images (whether inside a Kadence block OR A GUTENBERG BLOCK) have the TITLE attribute in the HTML replaced with “-x- Bear & Son Rosewood Trapper” – one value for every image, even though they are all from different posts. The value in the “Add missing TITLE attributes” field is “-x- %title%”, which produces “-x- Bear & Son Rosewood Trapper” for every image.

    Please help!!

    If I deactivate RankMath, the problem is resolved with nothing being substituted into the HTML.

    Sorry, I meant “stopping dealing with RankMath”, not “stopping dealing with Kadence” – my mistake.

    Hello,

    The ALT text that you see on the images is not coming from the setting under Image SEO as we have just changed that to include the initials “RM” and it’s not updating on the source code of the page.

    As you can see from one example image, the ALT text is present hence not being changed by our plugin, while the Title is not present and the function to add missing titles is running:
    Missing title

    Regarding the issue with the incorrect title, even if you run the default WordPress function get_the_title() on the homepage you get the same sentence being outputted.

    Since we use that default WordPress function to generate our own variable it’s expected to see this value.

    This seems to be caused by the fact that you are also setting the homepage as the shop page and when WordPress reads from the loop to get the title it fetches from one of the products in the loop.

    Don’t hesitate to get in touch if you have any other questions.

    Okay, some other developers gave me this code to turn on TITLE attributes in the HTML. Since this is what the “Add missing TITLE attributes” setting is supposed to do, I thought I might pass this along (since no one was able to help at RankMath):

    function kt_add_title_tag_to_img($attr, $attachment = null){
    	$attr['title'] = get_post($attachment->ID)->post_title;
    	return $attr;
    }
    add_filter('wp_get_attachment_image_attributes', 'kt_add_title_tag_to_img', 10, 2);

    This corrects the issue without using RankMath, good!

    Hello,

    Glad that you were able to sort the issue and appreciate taking the time to share the code snippet with us.

    Don’t hesitate to get in touch if you have any other questions.

Viewing 6 replies - 16 through 21 (of 21 total)

The ticket ‘Images Assigned Wrong TITLE Attribute Value In HTML’ is closed to new replies.