Would it be possible to add small avatars to main activity page like on Facebook ?

Comments

sirkitree’s picture

All display is through Views, so yes. Just takes a bit of theming know-how

Scott Reynolds’s picture

I would suggest actually Imagecache Profiles. This module now has Views formatters so you can pick an imagecache for the user picture

http://drupal.org/project/imagecache_profiles

DrakeRemory’s picture

If your view has a relationship with the user table (the default one already does) you can just add the user picture as a field.

Scott Reynolds’s picture

Right the the key is making the picture small. The default drupal setup will put a large picture there if they uploaded a large picture or a small picture if they uploaded a small picture. D6 user picture handling is virtually non-existant as it doesn't, out of the box resize and reshape.

Sirkitree mentioned that you can theme the specific View field and that will solve it. And I sugguested using that imagecache profiles as it will allow you to select from your imagecache sizes the size you want for your picture.

Thankfully, imagecache has been folded into core for Drupal 7.

drupallogic’s picture

thanks guys.

does any one know when activity 2 beta will be released ? it has been under dev. for months.

Scott Reynolds’s picture

Status: Active » Fixed

It will be ready when its ready :-D

this issue still needs to be addressed
#391670: Create an upgrade path

drupallogic’s picture

I don't think there needs to be an upgrade from 1 to 2. activities are not things like pics or videos :) so we can never mind.

the dev version doesn't come with pre-defined tokens phrases, will it be on the stable version ?

sirkitree’s picture

Status: Fixed » Closed (fixed)

it will not ship with default phrases.

the upgrade path is proly not going to happen, especially since there is functionality to generate activity records on an existing site.

but this is completely OT

blasthaus’s picture

i wonder does anyone have a simple solution to pull in the social avatar as the main user $picture and image cache it? i'd like to do this automatically upon user login, and ideally prompt the user that this pic will be used (box pre-checked, continue). if user un-checks box, then they can either upload a pic or else a default pic will become $picture. i'm using gigya socialize btw and really green on drupal so any guidance here would be greatly appreciated.
cheers -wil

Scott Reynolds’s picture

WAYYYYY off topic. Please this issue is closed and Your question has nothing to do with the issue

but i help you out anyways. http://drupal.org/project/avatar_selection

adam_c’s picture

I have image_cache and when I try to add an image field to the default view, the images do not appear.

You mentioned in an earlier post that if the user table relationship exists (which it does) then this should work. With respect to this, when I configure the image field in views, at the top where you have the relationship drop down, only 'node' is available. Could this be the problem?

I also have the problem of the UR_api not being available to the view, this maybe relevant to this problem, but perhaps not so I will start a new thread or find a similar one for that.

Scott Reynolds’s picture

image_cache != image_cache profiles. You can't use image_cache for profile pictures, or you are using nodes for profiles (like content_profile module). The field you most likely want to use is User > Picture.

This is most definitely doable so this issue is closed, and not a place for general Views help. If you are still having a serious issue and have in good faith tried hard to create the View following the instructions listed in this thread, please open a new issue and export your View to share with us.

adam_c’s picture

I appologise, I should have mentioned that I am using content profile and therefore user > picture is not adequate.

My avatars are an image content belonging to a content profile node.

rjbrown99’s picture

I have this working fine on my end with content profile.

You have a relationship Activity: User already assuming you are using the existing view as a starting point. Add a second relationship to Node: Content Profile with a relationship to Activity: User. Check require this relationship, and pick your content type. Then head down to Fields, pick your picture field, and make sure you use a reference back to the Content Profile.

In short, my "Relationships" looks like this:
Activity: Node
Activity: User
(Activity - User) Node: Content Profile

My field looks like:
(Content Profile) Content: Picture MyImageCachePreset

sirkitree’s picture

Component: Code » Documentation
Assigned: Unassigned » sirkitree
Category: feature » task
Status: Closed (fixed) » Active

Turning this into a task so that I remember to update the Views documentation for 2.x - Thank you.

Scott Reynolds’s picture

Bump. You wanted to document something sirkitree ??

sirkitree’s picture

When I get some downtime, yes, definitely.

dalad’s picture

I managed to have user avatar pictures in activity entries.
Note that:
1) the substitution is performed at execution time, so the avatars in messages are synchronized with the actual ones from the users.
2) the following method has the advantage of creating an avatar for EVERY username in the activity, even for the ones like "%requestee is now friend of %requester"
3) the substitution is performed on the assumption that username links have the form "mysite.com/profile/username", as seen in the regex of _render_user_avatars(). if you don't use clean urls, you might substitute "profile" with "user" in that expression and then load users by their matched id instead of their matched name by changing "name" to "uid" in the subsequent user_load.
4) Avatars dimension can be simply changed with CSS.

1) create a view field handler for the message field

/**
 * Field handler to provide the activity message
 */
class my_module_views_handler_field_message extends activity_views_handler_field_message {
	function query() {
		return activity_views_handler_field_message::query();
	}
	function pre_render($values) {
		return activity_views_handler_field_message::pre_render($values);
	}
	function render($values) {
		$status = activity_views_handler_field_message::render($values);
		$status = _render_user_avatars($status);
		return $status;
	}
	function _render_user_avatars($status) {
		preg_match_all("@<a[^<]*profile[^<]*</a>@", $status, $result, PREG_SET_ORDER);
		foreach ($result as $matches) {
			foreach ($matches as $match) {
				$username = strip_tags($match);
				$user = user_load(array("name" => $username));
				$token = "<span class='user-picture-token'>".theme("user_picture", $user).theme("username", $user)."</span>";
				$status = str_replace($match, $token, $status);
			}
		}
		return $status;
	}
}

2) Register the handler

/**
 * Implementation of hook_views_handlers().
 */
function my_module_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'my_module'),
    ),
    'handlers' => array(
      'my_module_views_handler_field_message' => array(
        'parent' => 'activity_views_handler_field_message',
      ),
    ),
  );
}

3) Hook in to the api, set to use the new handler

function my_module_views_api() {
	return array(
    'api' => 2,
	);
}

function my_module_views_data_alter(&$data) {
	$data['activity_messages']['message']['field']['handler'] = 'my_module_views_handler_field_message';
}

4) Rebuild cache and go
Go to admin/settings/performance and clear cache, then give it a go.

Scott Reynolds’s picture

Using the User relationship makes this way easier.

sirkitree’s picture

Status: Active » Closed (fixed)

Thanks dalad - I turned this into a documentation page.

http://drupal.org/node/908916

glitz’s picture

This is EXACTLY what I need, but using imagecache profile thumbnails.

I appreciate the supplied code, but Is there a way to elaborate on the steps I need to take?
In other words, Could you explain or point me to where/how I can perform the following steps?

1.create a view field handler for the message field
2.Register the handler
3.Hook in to the api, set to use the new handler

Thanks!
Chris

glitz’s picture

Ill also try using the User relationship method.
----

In addition to user avatars, Is there a way to add in cck imagefields into activity?

For instance if a cck type has a image field and a user uploads an image there, could I somehow reference that imagefield (maybe as a token)?

Thanks again,
Chris

glitz’s picture

i was able to get this to show as i wanted to but the query time is very slow. almost took 5 minutes for the view preview, and "Save" or "Preview" to occur

JohnnyW’s picture

Could you explain these steps in more detail? Like what files to manipulate, etc.

1.create a view field handler for the message field
2.Register the handler
3.Hook in to the api, set to use the new handler

THANKS!