aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2015-06-16 12:33:17 +0200
committerMarc Alexander <admin@m-a-styles.de>2015-06-16 12:33:17 +0200
commitdc9245dd7a5a13f67667df835957740b553d2313 (patch)
tree7bb1eb6e7c20a94e4e14fab371882cdb8e46ccbc /phpBB/includes/functions.php
parentc6308ee7c0681b5c99185f009e7a59f1c7c8f1d5 (diff)
parentd1c4f5bc352b89da7b0fba4925c68f596f623494 (diff)
downloadforums-dc9245dd7a5a13f67667df835957740b553d2313.tar
forums-dc9245dd7a5a13f67667df835957740b553d2313.tar.gz
forums-dc9245dd7a5a13f67667df835957740b553d2313.tar.bz2
forums-dc9245dd7a5a13f67667df835957740b553d2313.tar.xz
forums-dc9245dd7a5a13f67667df835957740b553d2313.zip
Merge pull request #3653 from callumacrae/ticket/13882
[ticket/13882] Lazy load the notification avatars.
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index f048eb549c..68020458c7 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -4813,10 +4813,11 @@ function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config
* @param array $row Row cleaned by \phpbb\avatar\manager::clean_row
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
+* @param bool $lazy If true, will be lazy loaded (requires JS)
*
* @return string Avatar html
*/
-function phpbb_get_avatar($row, $alt, $ignore_config = false)
+function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false)
{
global $user, $config, $cache, $phpbb_root_path, $phpEx;
global $request;
@@ -4854,7 +4855,28 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false)
if (!empty($avatar_data['src']))
{
- $html = '<img src="' . $avatar_data['src'] . '" ' .
+ if ($lazy)
+ {
+ // Determine board url - we may need it later
+ $board_url = generate_board_url() . '/';
+ // This path is sent with the base template paths in the assign_vars()
+ // call below. We need to correct it in case we are accessing from a
+ // controller because the web paths will be incorrect otherwise.
+ $phpbb_path_helper = $phpbb_container->get('path_helper');
+ $corrected_path = $phpbb_path_helper->get_web_root_path();
+
+ $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
+
+ $theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme';
+
+ $src = 'src="' . $theme . '/images/no_avatar.gif" data-src="' . $avatar_data['src'] . '"';
+ }
+ else
+ {
+ $src = 'src="' . $avatar_data['src'] . '"';
+ }
+
+ $html = '<img class="avatar" ' . $src .
($avatar_data['width'] ? ('width="' . $avatar_data['width'] . '" ') : '') .
($avatar_data['height'] ? ('height="' . $avatar_data['height'] . '" ') : '') .
'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';