MDL-59528 core: Add option to display fullname beside user picture
This commit is contained in:
@@ -201,6 +201,11 @@ class user_picture implements renderable {
|
||||
*/
|
||||
public $visibletoscreenreaders = true;
|
||||
|
||||
/**
|
||||
* @var bool Whether to include the fullname in the user picture link.
|
||||
*/
|
||||
public $includefullname = false;
|
||||
|
||||
/**
|
||||
* User picture constructor.
|
||||
*
|
||||
|
||||
@@ -2368,6 +2368,7 @@ class core_renderer extends renderer_base {
|
||||
* - alttext=true (add image alt attribute)
|
||||
* - class = image class attribute (default 'userpicture')
|
||||
* - visibletoscreenreaders=true (whether to be visible to screen readers)
|
||||
* - includefullname=false (whether to include the user's full name together with the user picture)
|
||||
* @return string HTML fragment
|
||||
*/
|
||||
public function user_picture(stdClass $user, array $options = null) {
|
||||
@@ -2425,6 +2426,11 @@ class core_renderer extends renderer_base {
|
||||
// get the image html output fisrt
|
||||
$output = html_writer::empty_tag('img', $attributes);
|
||||
|
||||
// Show fullname together with the picture when desired.
|
||||
if ($userpicture->includefullname) {
|
||||
$output .= fullname($userpicture->user);
|
||||
}
|
||||
|
||||
// then wrap it in link if needed
|
||||
if (!$userpicture->link) {
|
||||
return $output;
|
||||
|
||||
@@ -24,6 +24,7 @@ information provided here is intended especially for developers.
|
||||
used to perform implicit validation of submitted values - without the need to explicitly add the validation rules to
|
||||
every form. The method should accept a single parameter with the submitted value. It should return a string with the
|
||||
eventual validation error, or an empty value if the validation passes.
|
||||
* New user_picture attribute $includefullname to determine whether to include the user's full name with the user's picture.
|
||||
|
||||
=== 3.3.1 ===
|
||||
|
||||
|
||||
Reference in New Issue
Block a user