1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* User Stats non-themed user picture.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Bare user picture handler.
|
10
|
*/
|
11
|
class views_handler_field_user_picture_bare extends views_handler_field_user_picture {
|
12
|
function render($values) {
|
13
|
if (module_exists('image')) {
|
14
|
$output = '';
|
15
|
|
16
|
// When an image style is not defined, use the image style from the account settings.
|
17
|
$style_name = $this->options['image_style'];
|
18
|
if (empty($style_name)) {
|
19
|
$style_name = variable_get('user_picture_style', '');
|
20
|
}
|
21
|
|
22
|
// Load the picture file and get the uri.
|
23
|
if ($user_picture_fid = $this->get_value($values)) {
|
24
|
$user_picture = file_load($user_picture_fid);
|
25
|
$user_picture_filepath = $user_picture->uri;
|
26
|
} else {
|
27
|
$user_picture_filepath = variable_get('user_picture_default', '');
|
28
|
}
|
29
|
|
30
|
// Return empty string when either style_name or picture are unavailable.
|
31
|
if (empty($style_name) || empty($user_picture_filepath)) {
|
32
|
return $output;
|
33
|
}
|
34
|
|
35
|
// Use the user name for alt attribute.
|
36
|
$user_name = $values->{$this->aliases['name']} ? $values->{$this->aliases['name']} : variable_get('anonymous', t('Anonymous'));
|
37
|
$alt = t("@user's picture", array('@user' => $user_name));
|
38
|
|
39
|
// Output the picture with image_style.
|
40
|
if (file_valid_uri($user_picture_filepath)) {
|
41
|
$output = theme('image_style', array('style_name' => $style_name,'path' => $user_picture_filepath, 'alt' => $alt));
|
42
|
}
|
43
|
|
44
|
// Wrap the picture in a link to the user picture.
|
45
|
if ($this->options['link_photo_to_profile'] && user_access('access user profiles')) {
|
46
|
$uid = $this->get_value($values, 'uid');
|
47
|
$output = l($output, "user/$uid", array('html' => TRUE));
|
48
|
}
|
49
|
|
50
|
return $output;
|
51
|
}
|
52
|
}
|
53
|
}
|