Viewing 5 replies - 16 through 20 (of 20 total)
  • You can probably just use javascript to remove titles. (Add to header.php below “<body <?php body_class(); ?>>” to remove all titles from website). You could put a conditional if for titles you don’t want removed.
    A PHP solution would be better obviously.

    To remove titles:

    <script type="text/javascript">
        window.onload = function(){
    var titled = document.querySelectorAll('[title]');
    var numTitled = titled.length;
    var i = 0;
    for (i=0; i<numTitled; i++){
        titled[i].removeAttribute('title');
    }
        };
    </script>

    To remove alt:

    <script type="text/javascript">
        window.onload = function(){
    var titled = document.querySelectorAll('[alt]');
    var numTitled = titled.length;
    var i = 0;
    for (i=0; i<numTitled; i++){
        titled[i].removeAttribute('alt');
    }
        };
    </script>

    I forgot to mention that window.onload can only be used once so if you want to remove BOTH title and alt tags you need to combine the code into one or just move the code to footer and insert this:

    <script type="text/javascript">
    var titled = document.querySelectorAll('[alt]');
    var numTitled = titled.length;
    var i = 0;
    for (i=0; i<numTitled; i++){
        titled[i].removeAttribute('alt');
    }
    </script>
    <script type="text/javascript">
    var titled = document.querySelectorAll('[title]');
    var numTitled = titled.length;
    var i = 0;
    for (i=0; i<numTitled; i++){
        titled[i].removeAttribute('title');
    }
    </script>
    Thread Starter Dekadinious

    (@dekadinious)

    The javascript removing the title tag without removing the alt-tag worked perfectly!

    Thanks 🙂

    I second the title solution by kimsf. Thank you!

    However, does anyone know if this will effect SEO for the image? Thanks in advance.

    thank you for sharing

    • This reply was modified 7 years, 5 months ago by ieio.
Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Remove tooltips on product image’ is closed to new replies.