Hey all,

When a user on my site uploads a new photo, heartbeat still calls the url of their previous photo. This would be a simple annoyance if Drupal didn't delete the old photo, but now there are a bunch of not found icons in my stream. It would be awesome if the heartbeat-user-picture token would always call the latest user picture. Honestly I have no idea on how to do that, so I am posting this here in hopes someone can help.

Thanks.

Comments

Stalski’s picture

Status: Active » Fixed

By default, variables are logged to the database as is. So there is nothing I can do about that at logging time.
On runtime however, you could implement hook_heartbeat_theme_alter and loop through the messages by address to add the avatar. This is easy when you have the $heartbeatActivity->uid and $heartbeatActivity->actor.
I think there is even an example in the heartbeat_example module for this.

So in your case, some custom code will fix your problem.

If you are not a programmer, you can also choose display suite module where heartbeat exposes everything as field (message, time, avatar, ...). This will be a bigger chance to your site concept but Display Suite is definitely something to consider. It displays the nodes and users as well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

CoreyMoore’s picture

Stalski,

I really appreciate the help and this issue is fixed. I know I am breaking some rule here, but I really need clarification. I have been trying to figure this out for about a month and I am still stuck.

This is the code I am currently trying to use:

In my module

function MYMODULE_heartbeat_theme_alter(&$messages, HeartbeatAccess $stream) { 
	 foreach ($messages as $key => $message) { 
		$messages[$key]->message = theme('heartbeat_content', $message, $node);
		}
	}

In my template.php file

function MYTHEME_heartbeat_content($message, $node) {

  $output = '';

  $user = heartbeat_user_load($message->uid);
  $output .= '<div class="icon-left-margin">';
  $output .= '<span class="avatar">'. l(theme('imagecache', 'profile_image_50by50', $user->picture), 'user/'. $user->uid, array('html' => TRUE)) .'</span>';
  $output .= '</div>';

  // If the message has to be shown anyway (inside the message)
  $output .= '<div class="heartbeat-indent">';
  $output .= $message->message;
  //$output .= $message->rebuild_message();
  $output .= '</div>';

  return $output;
}

This code is pretty much lifted right from the example module. Yet when I use this code, it causes my messages to not display at all. I must be missing something here.

Stalski’s picture

Status: Closed (fixed) » Active

You did register the theme hook as mymodule_theme() ?

CoreyMoore’s picture

Whoops! That worked :)

Edit: Nevermind what I just wrote. This is my mistake.

CoreyMoore’s picture

Ok, I'm still having an issue. This is working for every heartbeat feed on the site EXCEPT for the Organic group activity block. Do I need to add something to the heartbeat_user_load for this to work in those blocks?

Stalski’s picture

No, with the theme alter approach, it's all in your hands. So if you override it for each message, it should work.
I have no idea from here where the problem could be, can't think of anything that varies between de og activity and the rest.