Consider adding theme support for responsive logo
-
Hi! Right now the
header.php
file hardcodes the logo image at the single size set by the user when customizing the site identity. But WordPress supports automatic generation of responsive image source code, and this would allow the logo image to automatically scale up and down according to the client device while maintaining a high resolution. Could you consider adding support for this in the theme?Here’s an example of what this change would look like:
diff --git a/header.php b/header.php index 5499723..8885d78 100644 --- a/header.php +++ b/header.php @@ -41,7 +41,16 @@ <div class="navbar-brand"> <?php if ( get_theme_mod( 'wp_bootstrap_starter_logo' ) ): ?> <a href="<?php echo esc_url( home_url( '/' )); ?>"> - <img src="<?php echo esc_url(get_theme_mod( 'wp_bootstrap_starter_logo' )); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>"> + <?php echo wp_get_attachment_image( + attachment_url_to_postid( get_theme_mod( 'wp_bootstrap_starter_logo' ) ), + 'large', + false, + array( + 'alt' => esc_attr( get_bloginfo( 'name' ) ), + 'class' => 'navbar-brand-logo', + ) + ); + ?>
and then in the CSS, you could add something like:
+.navbar-brand-logo { + height: 75px; + width: auto; +} +
Thank you for considering it.
- The topic ‘Consider adding theme support for responsive logo’ is closed to new replies.