Keyword

Removing placeholder avatars from comments

  • YannisDr
  • YannisDr's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 8 months ago #123862 by YannisDr
In my blog I do not use a login system, so all the commenters will have a placeholder avatar, something I do not wish. A random placeholder avatar system would be nice, but I understand that K2 does not have one. How can I remove them completely?

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 8 months ago #123863 by Yiota
First, you need to edit item.php of your template overrides. If you do not use already, create them by reading here: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

Open item.php and locate this code
<?php if($comment->userImage): ?>
				<img src="<?php echo $comment->userImage; ?>" alt="<?php echo JFilterOutput::cleanText($comment->userName); ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" />
				<?php endif; ?>

replace it with this code
<?php  
								
	$findme   = 'user.png';
        $pos = strpos($comment->userImage, $findme);   
             				
				if($comment->userImage && !$pos): ?>
				<img src="<?php echo $comment->userImage; ?>" alt="<?php echo JFilterOutput::cleanText($comment->userName); ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" />
				<?php endif; ?>

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum