I can find the 'author picture' in views, but there doesn't seem to be a way to get a random sample of all the user pics. Images appearing seem to be based on a random sampling of nodes, resulting in repeat images of members who have posted the most.

What gets me closer is http://drupal.org/node/76351, but I can't figure out how to call an imagecache preset instead a simple scaled copy of the user image. Here's the code that's working for me:

$count = 8;
$no_avatar = "themes/vuc/favicon.ico";;
$result = db_query_range(db_rewrite_sql("SELECT * FROM {users} u ORDER BY RAND()"), 0, $count);
  while ($user_info = db_fetch_object($result)) {
   if($user_info->uid){
       if($user_info->picture) {
               print '<div id="blockpic"><a href="/user/'.$user_info->uid.'"<img src="/'.$user_info->picture.'" width=86><br />
<a href="/user/'.$user_info->name.'">'.$user_info->name.'</a>
</div>';
       }
       else {
               print '<div id="blockpic"><a href="/user/'.$user_info->name.'"<img src="/'.$no_avatar.'" width=86><br />
<a href="/user/'.$user_info->name.'">'.$user_info->name.'</a>
</div>';
       }

    }
  }

I'd like the $user_info->picture to be based on an imagecache preset (which does exist). Thanks!

Comments

jenlampton’s picture

Title: Is it possible to use views to make a random user pciture block? » Views Integration, Please?
Component: Miscellaneous » Code
Category: support » feature

I think the request arphaus is trying to make is for views-integration. I would also like to see this feature.

ImageCache provides a drop-down of all presets when adding image fields to views, it would be nice if the same feature were available for 'author pictures'.

arphaus - to answer your question re views making a list of random sample of user pics...

What views does is provide a list of nodes that meets the criteria you define. Because users are NOT nodes, the only way you can get a random sampling user info that does not repeat is to create nodes that have a 1 to 1 relation to users. Then you add a filter of node:type to your view. I would suggest using the usernode module, but you can also check out node profile or bio.

I hope this helps.
Jen

skizzo’s picture

ImageCache provides a drop-down of all presets when adding image fields to views, it would be nice if the same feature were available for 'author picture'.

+1
that would be very useful, allowing to add scaled down "User: Author Picture" to "Table" type views.

grah’s picture

+1
same reason as skizzo.

Bricks and Clicks Marketing’s picture

Thanks for the response, Jen. Unfortunately, the social network I was building got blown out of the water by someone else's diy Ning site. Next time I build a social network, it would probably be worth $5/mo to use Ning instead of developing from scratch.

patchak’s picture

That feature would really be useful, and would really use imagecache's abilities IMO, I might sponsor a patch for this, anyone interested in getting sponsored for doing it??

Patchak

Richard_’s picture

This request is probably duplicate fo this: http://drupal.org/node/217278
I can chip-in for this feature..

v1nce’s picture

Status: Active » Closed (duplicate)