[Resolved] SVG image attributes

Home Forums Support [Resolved] SVG image attributes

Home Forums Support SVG image attributes

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #660251
    Daren

    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">
    
    GeneratePress 2.1.4
    GP Premium 1.7.2
    #660443
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You can just use CSS:

    .header-image {
        width: 254px;
        height: 48px;
    }

    Let me know if that works for you or not 🙂

    #660519
    Daren

    I know you can use css, I was wondering how yours prints directly to the <img tag.

    #660564
    Daren

    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

    #660723
    Tom
    Lead Developer
    Lead Developer

    You should have access to the HTML, but that depends on how you’re adding the logo.

    However, using CSS is just as effective.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.