Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Inline styles for site identity logo have to go!

Discussion in 'Misc WordPress Requests' started by Jacob Peattie, Mar 27, 2018.

  1. Jacob Peattie

    Guest

    Reply To: Inline styles for site identity logo have to go!, by Jacob Peattie


    Whatever i upload as logo get’s cropped instead of using the original image. The tag also gets a width and height attribute for no reason other than stupidity.

    The width and height attributes are not inline styles, nor is it stupidity to include them (inline styles are CSS rules inside the style="" attribute). It is in fact best practice because it lets the browser know that ‘natural’ size of the image. This means that the browser can reserve space for it so the page doesn’t jump around as the image loads. This improves the readability of your site as well as perceived performance.

    Adding width and height styles in CSS would not provide the same benefits because you’d be setting a fixed display size for the image that would not respond correctly to changes in the size of the containing element, such as in a responsive design. When using width and height attributes the browser will account for this and still provide the correct amount of space.

    The reason the width and height attributes are 200 and 74 respectively in your example is because those are the dimensions of your image. Your image is 200×74.

    If your theme is insisting on a specific logo size it is likely doing so because that’s all the layout supports. You would need to discuss this with the theme author.

    But if you want to try changing it you need to create a hook that removes support for custom logos and then re-adds it with your desired settings. Since parent themes are loaded after the child theme you need to hook your function in after the parent theme has loaded.


    function child_theme_setup() {
    remove_theme_support( 'custom-logo' );

    $args = array(
    'height' => 100,
    'width' => 400,
    'flex-height' => true,
    'flex-width' => true,
    'header-text' => array( 'site-title', 'site-description' ),
    );

    add_theme_support( 'custom-logo', $args );
    }
    add_action( 'after_setup_theme', 'child_theme_setup', 20 );


    Note the 20 priority in the add_action() call. This will ensure that it is run after the parent theme’s setup, which is likely at the default 10.

    Reply To: Inline styles for site identity logo have to go!
     
    #1

Share This Page

Monarch Social Sharing Plugin