Archived topic
Elements do not have explicit width and height (svg)
3 replies · Started by Rostyslav on August 8, 2021
Hello,
How can I add width and height to my svg logo?
Thanks!
Hi there,
Try this PHP snippet:
https://docs.generatepress.com/article/generate_logo_output/#setting-a-width-and-height
Adding PHP: https://docs.generatepress.com/article/adding-php/
Hi Leo,
I added the filter with the specified logo dimensions to my child theme functions file.
The rendered HTML didn't change. My image dimensions don't appear.
I tried adjusting the filter execution priority and still no luck. The following is my exact code, with logo dimensions 85w x 35h.
add_filter( 'generate_logo_output','tu_logo_atts', 10, 2 );
function tu_logo_atts( $output, $logo ) {
printf(
'<div class="site-logo">
<a href="%1$s" title="%2$s" rel="home">
<img width="85" height="35" class="header-image" src="%3$s" alt="%2$s" title="%2$s" />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
esc_url( apply_filters( 'generate_logo', $logo ) )
);
}
Hi Brendan,
Can you open a new topic for this? So you can use the private information so link us to a sample page from the site in question.
We may have to inspect if the filter is actually applying.
Let us know. Thank you.