Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1491038

    Hello, I need to disable tool tips on the gallery element across the entire site.

    #1491043

    Are you talking about the tooltips displayed by the browser itself when hovering over the image?
    They appear automatically if the image has a title attribute.

    However, if you have a gallery that displays images in a lightbox, this title attribute is also displayed as text in the bottom bar of the lightbox. Completely removing the title tag would therefore be suboptimal. For galleries, you can switch to displaying the description or caption instead, but this is not possible for all Enfold elements.
    So if it only affects the galleries on your site, you could do that, but you would then have to update the description of the images, for example.

    There is a snippet that, when placed in the child theme’s functions.php, temporarily removes this title tag on hover but adds it back when clicked:

    function temporary_removal_title_tags(){
    ?>
    <script>
      window.onload = function() {
        var elementsWithTitle = document.querySelectorAll('a, img, *[title]');
        for (var i = 0; i < elementsWithTitle.length; i++) {
            var element = elementsWithTitle[i];
    
            element.setAttribute("data-original-title", element.title);
    
            element.addEventListener("mouseenter", function() {
                this.title = ""; 
            });
    
            element.addEventListener("mouseleave", function() {
                this.title = this.getAttribute("data-original-title"); 
            });
    
            element.addEventListener("mousedown", function() {
                this.title = this.getAttribute("data-original-title");
            });
        }
      };
    </script>
    <?php
    }
    add_action('wp_footer', 'temporary_removal_title_tags');

    here you see that this script is working for all anchor elements or images – or all elements that have a title-tag

    #1491056

    Hi,

    Thanks for helping out @guenni007. Did that answer your question @Dunckley_Design?

    Best regards,
    Rikard

    #1491121

    Hi @guenni007 and @rikard, thanks for helping out. I’ve attached a screenshot below. I’m trying to disable the tooltip that hovers over the image in the gallery, especially on mobile, but would be ok just disabling it altogether.

    Mobile

    #1491124
    #top .avia-tooltip.avia-tt {
      display: none !important;
    }
    #1491125

    @guenni007 thank you!

    #1491134

    Hi,

    Thanks for the update, and thanks @guenni007 for helping out. We’ll close this thread for now then, please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Disable tooltip on gallery’ is closed to new replies.