Skip to content

Instantly share code, notes, and snippets.

@cdils

cdils/functions.php

Last active Dec 21, 2016
Embed
What would you like to do?
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