I was talking with Drewish on IRC about this the other day. I'd like to be able to choose a preset for user pictures like you can with imagefield. I had hoped to file this issue with a patch attached but I'm putting out the white flag. Views code is just too complex for my skill level at this point. Even with some hints, I still have no clue how to make this happen.

So I'm putting it out as a feature request. Would be lovely if someone who understands views 2 code could make a patch for this. It's very helpful to anyone making views of users. In my case, I wanted it for the "friend" list in advanced profile kit. But I'm sure there are uses beyond just me.

Thanks for your time,

Michelle

Comments

likewhoa’s picture

subscribing as this is something that would make using views+user pictures alot easier.

catch’s picture

Just found a use case for this, and this issue was the closest thing I found. I'm not much up on the Views 2 API yet though.

Taxonomy image does a similar thing.

There's also http://drupal.org/project/imagecache_profiles - which handles flushing presets as well - this might be the best place for this to live, although leaving it against imagecache for now.

As far as I got is that imagecache_profiles should use hook_views_data_alter() to add it's own handler. This adds the options for the imagecache presets, then in render it'd need to override theme_user_picture() with a custom theme function to add the right preset in (similar to that old lullabot article). That might be enough even.

michelle’s picture

-1 for putting this in imagecache profiles. Having to install another module just for imagecache and views to work together, especially a module that will cause other problems I then have to work around is not a good solution for me.

Michelle

catch’s picture

The only thing that's needed from imagecache profiles is the hook_user() to flush presets, which is pretty small, so could easily live wherever this ends up. I've not used imagecache_profiles before so no real opinion either way.

likewhoa’s picture

we shouldn't have to rely on another imagecache based module just to integrate the user profile picture field with views. The only way now to set imagecache presets to user picture fields in views is by theming at the moment it should just be integrated like when adding image fields.

sun’s picture

User Display API (http://drupal.org/project/user_display) is able to solve this issue in a more generic approach. Does not require any changes in ImageCache. However, requires some love, especially a port to D6, and ultimately, adding the low-level classification of theme('user*') calls to D7 core - so the module could/would remain as UI in contrib.

SlipAngel’s picture

I would also like to see this functionality added. It would seem like views 2 should be able to do this.

gausarts’s picture

subscribing, thanks

likewhoa’s picture

for those that haven't already figured out how to manipulate user pictures in views with theming and imagecache here it is.

if(!empty($row->users_picture)) {
  $profilename = check_plain($row->users_name);
  $resized_pic = theme('imagecache','Thumbnail',$row->users_picture, $profilename, $profilename);
} else {
  $profilename = check_plain($row->users_name);
  $resized_pic = theme('imagecache','Thumbnail','/files/no_avatar.jpg',profilename, $profilename);
};

$user_link = 'user/' . $row->uid;

print l($resized_pic, $user_link, $options = array(html => TRUE));
gausarts’s picture

Wonderful. Works like a charm. Small typo, though, missing "$" on line #6. Perhaps you can throw me the light to use realname.module, instead? Thanks.

michelle’s picture

@likewhoa: Yes, that will work, but this issue is about getting views support into imagecache itself so people don't need to do that. Let's please try to keep the issue on track so it doesn't get won't fix'd.

Michelle

gausarts’s picture

Awfully sorry for misbehaving. I was carried away. Gotta get back on track. Thanks for reminding.

michelle’s picture

Oh, I wouldn't call any of it "misbehaving". LOL! likewhoa is trying to help and for many people that snippet will be enough. But I didn't want the issue to get so offtrack that the maintainers just won't fix it because it's not actionable anymore.

Just to restate, what I'm looking for is the ability to choose the preset for the user picture from within the views UI like you can do now with imagefield.

Michelle

likewhoa’s picture

yea I didn't mean to take the focus off the suggested feature request, I just wanted to show the way it's done using views theming, It would be logical to have imagecache presets set instead of doing the theming and I look forward to seeing it implemented and hope a maintainer doesn't go ahead and set status to 'WON'T FIX' because this would be a 'I DON'T WANT TO FIX' to me.

sharifudinrizal’s picture

Hope this will be added too, since it's pretty much the last thing I need to have for a totally great view for users.

drewish’s picture

Status: Active » Fixed

i'm really thinking that http://drupal.org/project/imagecache_profiles is probably the best place for this. imagecache doesn't provide support for themeing user pictures so i don't think it makes sense to just add views user support. i'd be open to trying to merge in imagecache_profiles but i don't think we should do it half way.

michelle’s picture

Status: Fixed » Closed (won't fix)

Well, that's won't fix then. Too bad. This is a feature many people would love. But, since I'm not showing up with code in hand, I can't blame you for not being willing to do it.

Imagecache profiles won't work for this. If I figure it out, I guess I'll have to write my own module to make imagecache work with views. I don't know if/when that will happen but will report back if I do.

Michelle

sun’s picture

Instead of working on yet-another approach, I happily invite you to join forces for User Display API.

michelle’s picture

@sun: Trying to avoid having to install a module with all sorts of features for one simple thing. This issue is about one thing: Making a views "formatter" or whatever it's called there that lets you choose the imagecache preset to use with user pictures. All you should need for that is imagecache and views. But since both the imagecache and views maintainers have said "not in my module" the only alternative is a 3rd module to make imagecache and views work together.

Michelle

drewish’s picture

i'm not opposed to the idea i just don't want to have part B added without part A in first.

michelle’s picture

@drewish: I don't understand. What sort of theming would you like it to provide? If you mean overriding theme_userpicture(), that's a mess you don't want to get into and what imagecache profiles does, IIRC. The trouble is that you want different sizes in different places and it can be very hacky to determine what size you want when you are overriding a generic theme function like that. With views, it's very explicit. You want this view field to be this size. Same as imagefield does for imagefields in views.

Michelle

atelier’s picture

I'm one of the "many people" Michelle cited who would very much like to see this functionality added. This would be particularly useful for community-based sites, which, by necessity, already incorporate many other contributed modules. Adding to the overhead with yet another module (for something so basic) is something I'd rather avoid.

Geekish’s picture

I have Imagecache applied to user pictures in my views now, thanks to this thread: http://drupal.org/node/349331 (comment #24 especially helped me).

It uses Imagecache_Profiles, and a patch to the aforementioned module which gives it Views compatibility. If you know how to patch okay, you might want to give it a try. The maintainer seems rather busy elsewhere, so I don't know when he'll commit the patch...

Of course, this is no good if you are really trying to avoid having to add another module, but I felt the patched Imagecache_Profiles was worth the additional resources for me.

michelle’s picture

Just a note. I finally learned how to make a views field and it's actually not hard at all. So I will be implementing this myself. Since the imagecache folks don't want it, I guess it will be an APK feature when I get back to that in July.

Michelle

Michsk’s picture

Why should we not be able to manipulate user pictures with views and imagecache but be able to manipulate normal images. Thats just very odd to me.

michelle’s picture

Ugh... I really should learn to not write down that I'm going to do anything until it's done. 2 years later and I never did do this and likely won't any time soon, if ever.

Michelle

Michsk’s picture

lol