Nivo Slider: img.nivo-main-image without alt attribute (Lighthouse a11y/SEO)

Home › Forums › All Other Themes › Nivo Slider: img.nivo-main-image without alt attribute (Lighthouse a11y/SEO)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #235803
    Giovanni BasileGiovanni Basile
    Participant
    • Topics: 1
    • Replies: 0
    • Total: 1
    Member since: July 30, 2024

    Technical Description of the Problem (to be pasted into the ticket)

    I am encountering a persistent error in Lighthouse / Chrome DevTools → “Names and labels”:

    Image elements are missing [alt] attributes
    Reported selector: div.slider-main > div.slider-wrapper > div#slider > img.nivo-main-image
    Element: <img class=”nivo-main-image … lzl-cached” … src=”…” data-lzl-src=”…”>
    ➡️ The alt attribute is missing, not just empty.

    Technical Context

    The slider is based on the jQuery Nivo Slider. The logic creates/updates the main image with:

    var u = $(“<img/>”).addClass(“nivo-main-image”);

    u.attr(“src”, i.currentImage.attr(“src”));

    u.attr(“alt”, i.currentImage.attr(“alt”) || “”);

    Additionally, an update is triggered on the event:

    $(“#slider”).on(“nivo:animFinished”, …)

    to re-align src and alt after each transition.

    Current Result

    Despite efforts, Lighthouse continues to detect that the img.nivo-main-image element is missing the alt attribute, suggesting that:

    The alt is being removed/overwritten at runtime by another script, or

    There is a conflict with lazy-load (with classes like lzl-cached and attributes like data-lzl-src appearing in the DOM), which could:

    Replace the <img> element with a clone

    Rewrite the attributes and “drop” the alt

    Manage src/data-* without preserving the alt

    Note on Nivo Transitions

    Nivo generates “slices/boxes” during the animation by creating many internal <img> elements with alt=””. This is secondary; the Lighthouse error explicitly points to the main image (img.nivo-main-image), which lacks the alt attribute.

    Request to the Developer

    A “permanent” fix is needed to ensure that img.nivo-main-image always has an alt attribute in the final DOM, even with lazy-load active.

    Required Technical Actions (Checklist):

    Verify if a lazy-load plugin/script (e.g., lzl-*) is replacing img.nivo-main-image and removing the alt attribute.

    Ensure that when img.nivo-main-image is created/updated, the attribute is set with:

    setAttribute(“alt”, “…”) (not just .attr()), and/or

    A MutationObserver to restore alt if another script removes it.

    Alternatively: disable lazy-load specifically for the slider or exclude #slider img from optimizations that rewrite the markup.

    #235808
    Sonal S SinhaSonal S Sinha
    Moderator
    • Topics: 0
    • Replies: 31745
    • Total: 31745
    Member since: August 16, 2013

    Hi,

    Unfortunately your all themes package has expired.

    Kindly renew your package by buying it here: https://www.sktthemes.org/shop/all-themes/

    We look forward to welcoming you again into our family.

    Regards,
    Chris

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