Tagged: ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1345565

    If I add to functions.php…

    function remove_title_attr(){
    ?>
    <script>
    (function($) {
    	$(window).on('load', function(){
    		$('#wrap_all a').removeAttr('title');
    		$('#wrap_all img').removeAttr('title');
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'remove_title_attr');

    … it works great at hiding the tooltip, but it also hides the text under an image in the lightbox which is a Caption in the Gallery element. So it would seem that Gallery element captions share the same attribute as a tooltip? Anyway I can differentiate? I don’t want to show tooltips over gallery images, but I do want to show the Gallery image caption when the lightbox is being used.

    #1345583

    if you only want it for img and anchors – use instead:

    function temporary_removal_title_tags(){
    ?>
    <script>
      window.onload = function() {
          var links = document.querySelectorAll('a , img');
          for (var i = 0; i < links.length; i++) {
              var link = links[i];
              link.onmouseover = function() {
                  this.setAttribute("org_title", this.title);
                  this.title = "";
              };
              link.onmouseout = function() {
                  this.title = this.getAttribute("org_title");
              };
              link.onclick = function() {
                  this.title = this.getAttribute("org_title");
              };
          }
      };
    </script>
    <?php
    }
    add_action('wp_footer', 'temporary_removal_title_tags');
    #1345585

    Thank you @Guenni007, that works!

    #1345620

    Hi lzevon,

    We’re happy to hear that :)


    @Guenni007
    thanks for helping out :)

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Hiding tooltip also hides lightbox text (under image)’ is closed to new replies.