Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Are you talking about title tags? Link?

    Thread Starter Dekadinious

    (@dekadinious)

    Hello! The site is in maintenance right now, but yes, if I remove the image title=”whatever” when I inspect the element, the tooltip does not show.

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    WordPress adds these to post thumbnails, if we’re talking about the same things. You can give images better titles in your media library.

    Thread Starter Dekadinious

    (@dekadinious)

    Thank you for answering me.

    So there is no solution to just remove the fact that when you hover over the image with the mouse on the product page, the image name shows? If I don’t want to have the text there at all?

    Plugin Contributor Claudio Sanches

    (@claudiosanches)

    Of course you can remove.
    Just use the woocommerce_single_product_image_thumbnail_html and woocommerce_single_product_image_html for it ??

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Thread Starter Dekadinious

    (@dekadinious)

    Thank you for answering.

    Mike, the [edit: information in the] link you posted sadly did not work.

    Claudio, could you please explain a bit closer? Can I make a filter to put in my functions.php that fixes this for me? ??

    Thread Starter Dekadinious

    (@dekadinious)

    Claudio, do you know?

    Thanks!

    Try this in functions.php to chop out the alt parameter.

    add_filter ('woocommerce_single_product_image_html', 'my_function');
    function my_function($html) {
      $start = stripos($html, 'alt="');
      if ($start) {
        $end = stripos($html, '"', $start + 5);
        $html = substr($html, 0, $start - 1).substr($html, $end + 1);
      }
      return $html;
    }

    Thread Starter Dekadinious

    (@dekadinious)

    Hello again!

    Thank you for the reply. The alt-tag was strippet out, but the tooltip still shows. I changed it to this:

    add_filter ('woocommerce_single_product_image_html', 'my_function');
    function my_function($html) {
      $start = stripos($html, 'title="');
      if ($start) {
        $end = stripos($html, '"', $start + 5);
        $html = substr($html, 0, $start - 1).substr($html, $end + 1);
      }
      return $html;
    }

    But then nothing is stripped out. I probably have to strip out both the title and alt tags, but I don’t know how. Would appreciate the help!

    Thanks!

    “title” is 2 chars longer than “alt”, so alter “$start + 5” to “$start + 7”. See if that removes the title attribute. Sorry, not tested.

    Thread Starter Dekadinious

    (@dekadinious)

    Thank you so much for your help and time, I truly appreciate it.

    But sadly, that did not work ?? The script removes the alt tag with + 5, but not the title tag with + 7 and title=” in the correct field.

    Any more suggestions? Would really appreciate it!

    It sort-of worked. The enclosing a tag has a title attribute as well. That’s being removed but leaving the second title attribute in the img tag. So we need to remove two title attributes:

    add_filter ('woocommerce_single_product_image_html', 'my_function');
    function my_function($html) {
      $start = stripos($html, 'alt="');
      if ($start) {
        $end = stripos($html, '"', $start + 5);
        $html = substr($html, 0, $start - 1).substr($html, $end + 1);
      }
      $start = stripos($html, 'title="'); // attribute in a tag
      if ($start) {
        $end = stripos($html, '"', $start + 7);
        $html = substr($html, 0, $start - 1).substr($html, $end + 1);
      }
      $start = stripos($html, 'title="'); // attribute in img tag
      if ($start) {
        $end = stripos($html, '"', $start + 7);
        $html = substr($html, 0, $start - 1).substr($html, $end + 1);
      }
      return $html;
    }

    Thread Starter Dekadinious

    (@dekadinious)

    Thank you for using so much of your time on this problem.

    It sadly does not work. The alt tag is removed, the title tag is still there and the tooltip still shows.

    Could you to post the markup for your product_image div. It’ll be something like this or post the link to a product page after you go live.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Remove tooltips on product image’ is closed to new replies.