Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1490521

    Hi, I’ve tried multiple codes to remove the image title on mouse hover, but it’s not disappearing.

    It doesn’t show up if I’m logged into wp-admin, but once I logout I still see it.

    Using Chrome on Mac

    Codes I’ve tried

    Quick CSS

    /*Remove image title on hover*/
    img[title] {
            pointer-events: none;
        }

    Functions.php

    /*Remove image alt text on hover*/
    function remove_title_attr(){
    ?>
     <script>
    jQuery(window).on('load', function(){
    jQuery('#wrap_all a').removeAttr('title');
    jQuery('#wrap_all img').removeAttr('title');
    });
     </script>
    <?php
    }
    add_action('wp_footer', 'remove_title_attr');
    #1490524

    Hey sjahan,

    Thank you for the inquiry.

    We’ve made a few edits to the script — please try it again. Make sure to clear your cache before checking the page.

    /* remove image and link title attributes on hover */
    function remove_title_attr(){
    ?>
    <script>
    jQuery(document).ready(function($){
        $('#wrap_all a, #wrap_all img').removeAttr('title');
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'remove_title_attr');
    
    

    Best regards,
    Ismael

    #1490529

    Hi, I cleared my cache and also tried in an incognito window and another laptop that hasn’t visited the site before but I still see the hover text

    #1490531

    Hi,

    We edited the functions.php file and adjusted the priority of the action hook. It should be working properly now.

    Best regards,
    Ismael

    #1490532

    Hi, thank you! That seems to have worked on the Services page which uses the Image box, but I still see it on the Home and About pages that are leveraging the Masonry Gallery. I’ve cleared my cache again just to double check but it’s still there. Do you see it on your end?

    #1490549

    Hi,
    Try this in your child theme functions.php:

    function remove_tool_tip() { ?>
      <script>
    window.onload = function() {
      var links = document.querySelectorAll('a, img, *[title]');
      for (var i = 0; i < links.length; i++) {
          var link = links[i];
          link.onmouseover = function() {
              this.setAttribute("data-tooltip", this.title);
              this.title = "";
          };
          link.onmouseout = function() {
              this.title = this.getAttribute("data-tooltip");
          };
          link.onmousedown = function() {
              this.title = this.getAttribute("data-tooltip");
          };
      }
    };
    </script>
      <?php
    }
    add_action( 'wp_footer', 'remove_tool_tip', 99 );

    Best regards,
    Mike

    #1490551

    That seems to have worked, thank you!

    #1490556

    Hi,

    Great! Let us know if you have more questions. Have a nice day.

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Image Title on Hover’ is closed to new replies.