WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Hide Alt Title on Thumbnail Mouseover (13 posts)

  1. markusday
    Member
    Posted 2 years ago #

    I would like to hide the image title when someone puts their mouse over the thumbnail image. I know this is something easy, just don't know where to start. Anyone?

    Put your mouse over the thumbnails in this url: http://www.filedcontent.com/

  2. Those are coming from the title attribute on the img tag.

    I don't know how you're generating your thumbnails, but if you can access the code directly, just remove all the title attributes.

    For example, remove title="1193528_95902129" from this:

    <img width="150" height="150" src="http://www.filedcontent.com/wp-content/uploads/2011/06/1193528_95902129-150x150.jpg" class="attachment-thumbnail" alt="1193528_95902129" title="1193528_95902129" /></a>

    Incidentally, I strongly recommend that you make the alt tags something descriptive so that visually impaired people and those who have turned off images will get a description of the image instead of just a number.

  3. markusday
    Member
    Posted 2 years ago #

    Thx zoo! Anyone else??

  4. Kraignos
    Member
    Posted 2 years ago #

    You could try the javascript way. This example with jquery :

    First, in the header.php file of your theme, add this code the line before the closing head tag (</head>) :

    <!-- include the latest version of jQuery-->
    <script src="http://code.jquery.com/jquery-latest.js"></script>

    (only if your theme isn't already using jQuery)

    Then, add this code to the footer.php file of your theme :

    <script type="text/javascript">
    /* The first line waits until the page has finished to load and is ready to manipulate */
    $(document).ready(function(){
        /* remove the 'title' attribute of all <img /> tags */
        $("img").removeAttr("title");
    });
    </script>

    Yeah. As simple as that.

  5. markusday
    Member
    Posted 2 years ago #

    Thx Kraignos! This is an excellent alternative!

  6. Kraignos
    Member
    Posted 2 years ago #

    Yep, very straightforward :)
    Be aware though, that as this is javascript based, people who turned Javascript off in their browser config will still see the titles on rollover. Don't have the stats but it shouldn't be a bunch of people...

  7. Peter vanDoorn
    Member
    Posted 2 years ago #

    When you insert the image into a post you get the option to edit the title. This can be edited after you post too, so just go back into each post and edit those images!

  8. Kraignos
    Member
    Posted 2 years ago #

    petervandoorn is right, this would be the best and cleaner way to do this. And not so long if you don't have many pics.

  9. bfred.it
    Member
    Posted 2 years ago #

    No javascript required:

    add_filter( 'wp_get_attachment_image_attributes', 'remove_image_text');
    function remove_image_text( $attr ) {
    	unset($attr['alt']);
    	unset($attr['title']);
    	return $attr;
    }
  10. negrelja
    Member
    Posted 2 years ago #

    I tried the method posted by "bfred.it" with no luck. I added the function to my "functions.php" but it had no effect on any of my pages. Please let me know if I'm missing something or I will just have to stick with the jQuery .removeAttr function. Thanks.

  11. Lulupard
    Member
    Posted 2 years ago #

    negrelja, it worked for me just now

  12. Mark
    Member
    Posted 1 year ago #

    negrelja, that kinda works with twenty eleven, but instead of the title now the rollover reads "Permalink to *title of post*". Just an fyi...

  13. m-dawg
    Member
    Posted 1 year ago #

    Kraignos, I know it's an old topic but thank you! Worked like a dream.

Topic Closed

This topic has been closed to new replies.

About this Topic