Skip to content

Instantly share code, notes, and snippets.

@cdils
Last active December 21, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdils/fb1e7e3481b069e01ac8 to your computer and use it in GitHub Desktop.
Save cdils/fb1e7e3481b069e01ac8 to your computer and use it in GitHub Desktop.
Display a Logo (or Avatar) Before the Site Title - See accompanying tutorial at http://www.carriedils.com/display-logo-before-site-title/
<?php // remove this line.
add_action( 'genesis_header', 'cd_site_image', 5 );
/**
* Output image before site title.
*
* Checks to see if a header image exists. If so, output that in an `img` tag. If not, get
* the Gravatar associated with the site administrator's email (under Settings > General).
*
* @see get_header_image() Retrieve header image for custom header.
* @see get_avatar() Retrieve the avatar `<img>` tag for a user.
*
* @return string HTML for site logo/image.
*/
function cd_site_image() {
$header_image = get_header_image() ? '<img alt="" src="' . get_header_image() . '" />' : get_avatar( get_option( 'admin_email' ), 224 );
printf( '<div class="site-image">%s</div>', $header_image );
}
.site-header .site-image img {
border-radius: 50%;
display: block;
height: 100px;
margin: 0 auto 20px;
width: 100px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment