WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Live Comment Preview] Gravatars shown in preview even if turned off in blog settings (5 posts)

  1. Stephanie Leary
    Member
    Posted 6 years ago #

    Right now, the plugin isn't checking to see whether the blog allows avatars, only whether this version of wordpress supports them. It ought to check both -- it's misleading for the avatar to be shown in the preview when it won't be in the posted comment.

    I think if (!empty(get_option('show_avatars'))) is the right code for that option -- or, Otto says get_avatar() has that check built in -- but my brief attempts to make it work have resulted in disaster.

    http://wordpress.org/extend/plugins/live-comment-preview/

  2. Stephanie Leary
    Member
    Posted 6 years ago #

    Got it to work. Here are the changes, if you'd like to incorporate them:

    line 35:

    // Customize this string if you want to modify the preview output
    	// %1 - author's name (as hyperlink if available)
    	// %2 - comment text
    	// %3 - gravatar image url
    	$previewFormat = '
    		<ol class="commentlist" style="clear: both; margin-top: 3em;">
    			<li id="comment-preview" class="alt" style="overflow: hidden;">';
    	if (get_option('show_avatars') != '0')
    		$previewFormat .= '<img src="%3" alt="" class="avatar avatar-' . $gravatar_size . '" width="' . $gravatar_size . '" height="' . $gravatar_size . '"/>';
    	$previewFormat .= '<cite>%1</cite> Says:
    				<br />
    				%2
    			</li>
    		</ol>';

    around line 200:

    if (get_option('show_avatars') != '0') $previewFormat = str_replace("%3", "' + gravatar + '", $previewFormat);

  3. Stephanie Leary
    Member
    Posted 6 years ago #

    n/m, that worked in testing but removed the comment text in production.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    get_avatar does have the check built in. Look at the code in the default theme:
    <?php echo get_avatar( $comment, 32 ); ?>

    That's all it takes in a theme.

    Live Comment Preview, on the other hand, is *live*. It's generated via some other means, not via the PHP code.

  5. Stephanie Leary
    Member
    Posted 6 years ago #

    I know. I just can't seem to make it work. For now I've disabled the avatar in the CSS: #comment-preview img.avatar { display: none; }

Topic Closed

This topic has been closed to new replies.

About this Topic