Archived topic
SVG image attributes
4 replies · Started by Daren on August 26, 2018
When using svg images how do you add the width and height attributes, I added the image with the customizer.
Mine
<img class="header-image" alt="dotmycom" src="https://dotmycom.com/wp-content/uploads/site-logo.svg" title="dotmycom">
Yours
<img src="https://generatepress.com/wp-content/themes/generatepress_official/images/logo.svg" alt="GeneratePress" width="254" height="48" class="header-image">
Hi there,
You can just use CSS:
.header-image {
width: 254px;
height: 48px;
}
Let me know if that works for you or not :)
I know you can use css, I was wondering how yours prints directly to the <img tag.
That did fix my issue without JS. I did find though using JS inputs them to the attr directly.
$( '.header-image' ).attr( { 'height': '150', 'width': '450' } );
Thanks
You should have access to the HTML, but that depends on how you're adding the logo.
However, using CSS is just as effective.