• Hi,

    I’m currently making a theme based on ‘sandbox’ I’ve been able to to change the default gravatar by linking to one that i’ve placed in the themes image folder…

    I would prefer to use a dynamic link using the template path. Here’s what I’ve got so far

    function nneon_commenter_link() {
    	$commenter = get_comment_author_link();
    	if ( ereg( '<a[^>]* class=[^>]+>', $commenter ) ) {
    		$commenter = ereg_replace( '(<a[^>]* class=[\'"]?)', '\\1url ' , $commenter );
    	} else {
    		$commenter = ereg_replace( '(<a )/', '\\1class="url "' , $commenter );
    	}
    	$avatar_email = get_comment_author_email();
    	$avatar_size = apply_filters( 'avatar_size', '32' ); // Available filter: avatar_size
    	$grav_url = "http://website.com/wp-content/themes/xoxo/images/gravatar.jpg";
    	$avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( $avatar_email, $avatar_size, $grav_url ) );
    	echo $avatar . ' <span class="fn n">' . $commenter . '</span>';
    }

    what do i need to do in order to use:

    <?php bloginfo('template_directory'); ?>/images/gravatar.jpg

    ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try,

    Not sure of the php but how about

    $temp_url = bloginfo('template_url')

    Then

    $grav_url = $temp_url/images/gravatar.jpg

    Thread Starter nneon

    (@nneon)

    Yeah that’s what I tried to do at first… but for some reason this is the result in the source code:

    <div class="comment-author vcard">http://website.com/wp-content/themes/xoxo<img alt='' src='http://www.gravatar.com/avatar/?d=/images/gravatar.jpg&amp;s=32' class='photo avatar avatar-32 avatar-default' height='32' width='32' /> <span class="fn n"><a href='http://wordpress.org/' rel='external nofollow'>Mr WordPress</a></span></div>

    I guess if there’s anyone that knows the correct syntax to use that would be real helpful ?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Linking gravatar using template path?’ is closed to new replies.