- This topic has 10 replies, 4 voices, and was last updated 5 years, 4 months ago by Leo.
-
AuthorPosts
-
September 5, 2018 at 1:25 pm #669736Dan
Hello,
How can I filter out the title attribute from the logo?
I don’t want the small tooltip to show up once hovering over the image.The action hook is this (inside inc/structure/header.php)
$attr = apply_filters( 'generate_logo_attributes', array( 'class' => 'header-image', 'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), 'src' => $logo_url, 'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), ) );
Thanks,
DanSeptember 5, 2018 at 1:46 pm #669745LeoStaffCustomer SupportHi Dan,
Give this filter a shot:
https://docs.generatepress.com/article/generate_logo_output/Let me know if this helps ๐
September 5, 2018 at 2:08 pm #669782DanThanks Leo,
I modified the filter a bit to this (to remove the title attribute):add_filter( 'generate_logo_output', 'tu_no_logo_title', 10, 3 ); function tu_no_logo_title( $output, $logo_url, $html_attr ) { printf( '<div class="site-logo"> <a href="%1$s" rel="home"> <img %3$s /> </a> </div>', $html_attr ); }
but it removed the logo altogether.
Still, I don’t see where it removes the ‘title’ from the img tag.Dan
September 5, 2018 at 2:21 pm #669794LeoStaffCustomer SupportWhat if you simply remove the site title from Site Identity in the customizer?
September 5, 2018 at 2:26 pm #669797LeoStaffCustomer SupportThis solution should also work:
https://generatepress.com/forums/topic/hide-tooltip-when-hover-on-header-image/#post-417144September 6, 2018 at 6:11 am #670213DanThanks Leo,
The last solution did the trick as I didn’t want to remove the title completely from the site.Dan
September 6, 2018 at 8:19 am #670376LeoStaffCustomer SupportNo problem ๐
December 17, 2018 at 6:24 am #758979MichaelI’m also trying to remove or change the title attribute text from the img tag in the site logo. The issue is that the alt-text and the title are the same, which generates an accessibility error.
When I use the second fix,
add_filter( 'generate_logo_title', 'lh_remove_logo_alt' ); function lh_remove_logo_alt() { return ''; }
or anything with the ‘generate_logo_title’ filter it removes both the alt-text and the title attribute, which creates the more serious “no alt-text” error.
Is there a way to remove the title text without affecting the alt-text?
December 17, 2018 at 10:59 am #759389TomLead DeveloperLead DeveloperHi there,
Try this:
add_filter( 'generate_logo_attributes', function( $atts ) { unset( $atts['title'] ); return $atts; } );
December 17, 2018 at 11:45 am #759417MichaelThat did the trick perfectly! Thank you so much!
Is there a similar snippet/filter for the navigation search? The title on the
<li>
tag is the same as the screen reader text inside.Thanks again!
December 17, 2018 at 1:20 pm #759506LeoStaffCustomer SupportCan you open a new topic for the separate question?
Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.