Avatars Display Integration

Started by Pipke, February 15, 2020, 07:43:21 PM

Previous topic - Next topic

Pipke

Link to the mod

Avatars Display Integration

For SMF 2.1.x (Hook install)
Tested only with the SMF default theme...but should work with other themes aswell!

What does this mod do...
- Poster or user avatar display integration on: (Note: This mod will display the default/initial avatar when user has posted or mentioned as guest.)
  • Board index
  • Unread, Update and Message index
  • Personal Message index
  • Alert list
  • Top section dropmenu
  • Topic title header
  • Recent post index
  • Recent post info center
  • Memberlist
  • Who's Online page
  • Search result
  • When using bbc @mention member name in posts
  • Other costum places*

- Layout the avatar:
  • With shadow
  • As a circle/square/curved shape
  • Add connection status overlay
  • Initial avatar of displayname

*Other costum places:
How to add user avatar anywhere in your template file from mods maybe, simple type:
data-adi-id="{userid}"

How to example in template file:
Code (find) Select

<div class="most_downloaded"><a href="'.$last['href'].'"><b>'.$last['name'].'</b></a></div>

Code ("replace by") Select

<div class="most_downloaded">data-adi-id="'.$last['user']['id'].'"<a href="'.$last['href'].'"><b>'.$last['name'].'</b></a></div>


How to style your costum output element:
<span class="{whatever}">data-adi-id="{userid}"</span>

License
* This SMF modification is subject to the BSD 2-Clause License

Admin settings
- Admin->Forum->Attachments and Avatars->Avatar Settings

Languages
- English
- Turkish by gevv
- Russian by Bugo
- Spanish_latin by Rock Lee␏ (not complete anymore)
- Dutch by @rjen
- Portuguese_pt by marcosbr

Changelog
Version 1.5.7 - Mar 18, 2024
- Fixed v1.5.6 wich had different versions of files

Version 1.5.6 - Nov 22, 2023
- Fixed who's online page buffer bug

Version 1.5.5 - Nov 21, 2023
- Fixed css style rule for redirection boards and empty(no topics inside) boards on index
- Updated languages Dutch and Russian
- Added language Portuguese_pt
- Added collaboration with the 'Topic Solved' mod

Version 1.5.4 - Nov 26, 2022
- Fixed who's online page buffer bug, due Who.template update
- Added style for avatar: Curved (square shape with rounded corners)

Version 1.5.2 - Mar 1, 2022
- Fixed responsive css for boardindex

Version 1.5.1 - Feb 28, 2022
- Fixed css for @mentions avatar in posts
- Added dutch language

Version 1.5 - Feb 27, 2022
- Fixed error 500 blank page due missing global var
- Fixed Undefined index: current_action
- Added option: Display avatar poster recent posts on info center

Version 1.4.2 - Aug 4, 2021
- Fixed Trying to access array offset on value of type null

Version 1.4.1 - Aug 4, 2021
- Fixed Undefined array key "profile_of"

Version 1.4 - Aug 3, 2021
- Fixed Undefined index global $txt var "profile_of", it doesnt exist anymore in 2.1 RC4

Version 1.3 - Jul 19, 2021
- Fixed error message when uninstalling

Version 1.2 - Mar 7, 2020
- Fixed anchor bbc @mention member name 'before the @name link'
- Fixed Undefined index: alert icon

Version 1.1 - Mar 4, 2020
- Added option avatar Who's Online page
- Optimized several css rules
- Fixed css for the 'who likes posts' avatar position
- Fixed comparison operator
- Fixed initial avatar for guests when using bbc @Member in posts and at the recent post index

Version 1.0 - Jan 28, 2020
- Initial Release
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Hatshepsut

I have istalled this mod, but user avatars in related posts in topics was resized from 100 to 65 pixels.
Is it possible to restore their usual size of 100 pixels?

Pipke

Quote from: Hatshepsut on February 16, 2020, 02:14:02 AM
I have istalled this mod, but user avatars in related posts in topics was resized from 100 to 65 pixels.
Is it possible to restore their usual size of 100 pixels?
Yes, you can by change the mod css file at ...Themes/{your_theme}/css/AvatarsDisplayIntergration.css
also be sure to set these settings at Admin->Forum->Attachments and Avatars->Avatar Settings:

  • Maximum width of external avatar
  • Maximum height of external avatar
to 100

Code (find) Select

li.avatar, .avatar, .poster .avatar[data-adi~="avatar"], #profileview .avatar[data-adi~="avatar"], #profileview .adi_item_context {
width: 65px;
height: 65px;
line-height: 60px;
font-size: 42px;
}

Code (replace by) Select

li.avatar, .avatar, .poster .avatar[data-adi~="avatar"], #profileview .avatar[data-adi~="avatar"], #profileview .adi_item_context {
width: 100px;
height: 100px;
line-height: 90px;
font-size: 70px;
}

and
Code (find) Select

#profileview [data-adi~="back"], .avatar [data-adi~="back"] { /* ok */
right: 0px;
    padding: 8px;
    bottom: 0px;
}

#profileview [data-adi~="front"], .avatar [data-adi~="front"] { /* ok */
right: 2px;
    padding: 6px;
    bottom: 2px;
}

Code (replace by) Select

#profileview [data-adi~="back"], .avatar [data-adi~="back"] { /* ok */
right: 8px;
    padding: 8px;
    bottom: 0px;
}

#profileview [data-adi~="front"], .avatar [data-adi~="front"] { /* ok */
right: 10px;
    padding: 6px;
    bottom: 2px;
}


you can adjust the pixels to your wishes, i just point out how to do it.


"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

wylekk

Hi.
Conflict with the Optimus mod.

Type of error: Database
Database Error: Not unique table/alias: 'a' https://site/index.php?topic=10.0
/Sources/Display.php (Line 182)

wylekk

Translation into Russian language
AvatarsDisplayIntegration Files.russian.php and AvatarsDisplayIntegration.russian-utf8.php must be utf8 encoded

<?php
/*
 * @package Avatars Display Integration
 * @version 1.0
 * @author Pipke http://www.simplemachines.org/community/index.php?action=profile;u=314795
 * @copyright Copyright (C) 2020, Pipke
 * @All rights reserved. 
 * @This SMF modification is subject to the BSD 2-Clause License
 *
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

$txt['adi_settings_title'] = 'Интеграция аватаров';
$txt['adi_layout_title'] = 'Дизайн аватаров';
$txt['adi_boardindex'] = 'Показать аватар с последним ответом в разделах форума';
$txt['adi_message_first'] = 'Показать аватар автора темы в "Непрочитанных сообщениях" и "Темах с непрочитанными ответами"';
$txt['adi_message_last'] = 'Показать аватар с последним ответом в "Непрочитанных сообщениях" и "Темах с непрочитанными ответами"';
$txt['adi_topic_header'] = 'Показать аватар автора в заголовке темы';
$txt['adi_recent_posts'] = 'Показать аватар в "Последних сообщениях"';
$txt['adi_memberlist'] = 'Показать аватар в "Списке пользователей"';
$txt['adi_search_posts'] = 'Показать аватар в "Результате поиска"';
$txt['adi_mentions'] = 'Показать аватар при использовании участником бб-кода @mention в сообщениях...';
$txt['adi_avatar_shadow'] = 'Добавить тень ко всем аватарам';
$txt['adi_avatar_shape'] = 'Сделать все аватары круглыми';
$txt['adi_log_in'] = 'в сети';
$txt['adi_log_un'] = 'не в сети';
$txt['adi_icon_overlay'] = 'Наложить значок подключения на аватар, если пользователь находится в сети или нет...';
$txt['adi_icon_both'] = 'для обоих вариантов';
$txt['adi_icon_online'] = 'только если в  сети';
$txt['adi_none'] = 'пожалуйста, не надо';
$txt['adi_mention_before'] = 'перед ссылкой @name';
$txt['adi_mention_after'] = 'после ссылки @name';
$txt['adi_mention_no_name'] = 'и скрыть ссылку @name';
$txt['adi_icon_shape'] = 'Сделать значок статуса подключения круглым';
$txt['adi_initials'] = 'Перезаписать аватар по умолчанию с инициалом отображаемого имени';
$txt['adi_view_your_profile'] = 'Просмотр профиля';
$txt['adi_you_are_logged_in'] = 'Вы в сети';
$txt['adi_unknown_user'] = 'ID пользователя:';

?>


Regards!

Hatshepsut

Quote from: Pipke on February 16, 2020, 03:56:53 PM
Quote from: Hatshepsut on February 16, 2020, 02:14:02 AM
I have istalled this mod, but user avatars in related posts in topics was resized from 100 to 65 pixels.
Is it possible to restore their usual size of 100 pixels?
Yes, you can by change the mod css file at ...Themes/{your_theme}/css/AvatarsDisplayIntergration.css


Thanks :)

I have found one bug:

After installing this mod, when I view users online (and set list to "Everyone"), I get an error message displayed on white screen:

array(7) { [0]=> array(3) { ["file"]=> string(50) "/home/bulataka/public_html/test/Sources/Errors.php" ["line"]=> int(290) ["function"]=> string(9) "log_error" } [1]=> array(3) { ["file"]=> string(69) "/home/bulataka/public_html/test/Sources/AvatarsDisplayIntegration.php" ["line"]=> int(555) ["function"]=> string(17) "smf_error_handler" } [2]=> array(3) { ["file"]=> string(48) "/home/bulataka/public_html/test/Sources/Subs.php" ["line"]=> int(4834) ["function"]=> string(27) "adi_integrate_theme_context" } [3]=> array(3) { ["file"]=> string(48) "/home/bulataka/public_html/test/Sources/Subs.php" ["line"]=> int(3581) ["function"]=> string(21) "call_integration_hook" } [4]=> array(3) { ["file"]=> string(48) "/home/bulataka/public_html/test/Sources/Subs.php" ["line"]=> int(3652) ["function"]=> string(17) "setupThemeContext" } [5]=> array(3) { ["file"]=> string(48) "/home/bulataka/public_html/test/Sources/Subs.php" ["line"]=> int(3274) ["function"]=> string(15) "template_header" } [6]=> array(3) { ["file"]=> string(41) "/home/bulataka/public_html/test/index.php" ["line"]=> int(154) ["function"]=> string(6) "obExit" } } Error loop.

Forum details:

Forum version: SMF 2.1 RC2 (more detailed)
Current SMF version: SMF 2.1 RC2
GD version: bundled (2.1.0 compatible)
MySQLi engine: MariaDB
MySQLi version: 10.3.22-MariaDB-log
PHP: 7.3.13 (more detailed)
Server version: Apache

Pipke

@Hatshepsut thanks for the report.
found the bug: well actually its not a bug, my mod runs on the wrong action page and that is causing the Undefined index: avatar at action=who
here is the fix:

in .../Sources/AvatarsDisplayIntegration.php

Code (find line 548) Select

if ((isset($context['members']) && !empty($context['members'])) && $context['current_action'] = 'mlist' && $modSettings['adi_memberlist'])

Code (replace by) Select

if ((isset($context['members']) && !empty($context['members'])) && $context['current_action'] == 'mlist' && $modSettings['adi_memberlist'])


ill update the fix in next release.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Pipke

Quote from: wylekk on February 16, 2020, 04:38:19 PM
Hi.
Conflict with the Optimus mod.

Type of error: Database
Database Error: Not unique table/alias: 'a' https://site/index.php?topic=10.0
/Sources/Display.php (Line 182)


Do you have more info, i cannot reproduce that, maybe some Backtrace information <- you can find that in the smf error logs
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Hatshepsut

Quote from: Pipke on February 17, 2020, 04:46:59 PM
@Hatshepsut thanks for the report.
found the bug: well actually its not a bug, my mod runs on the wrong action page and that is causing the Undefined index: avatar at action=who
here is the fix:

in .../Sources/AvatarsDisplayIntegration.php

Code (find line 548) Select

if ((isset($context['members']) && !empty($context['members'])) && $context['current_action'] = 'mlist' && $modSettings['adi_memberlist'])

Code (replace by) Select

if ((isset($context['members']) && !empty($context['members'])) && $context['current_action'] == 'mlist' && $modSettings['adi_memberlist'])


ill update the fix in next release.


Thanks for the fix! It works :)

-Rock Lee-

It looks very good I'm going to try it in a place that I'm maintaining and looking for something similar. I also leave attached the translation into Latin Spanish 8)!


Regards!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

wylekk

QuoteDo you have more info, i cannot reproduce that, maybe some Backtrace information <- you can find that in the smf error logs

If you enable the "Use the image from the first topic message in the meta tag og:image" option in the Optimus mod settings"

Getting an error



Conflict code in Optimus

if (allowedTo('view_attachments') && !empty($modSettings['optimus_og_image'])) {
$topic_selects[] = 'COALESCE(a.id_attach, 0) AS og_image_attach_id';
$topic_tables[]  = 'LEFT JOIN {db_prefix}attachments AS a ON (a.id_msg = t.id_first_msg AND a.width > 0 AND a.height > 0)';

         
Conflict code in AvatarsDisplayIntegration

// Job for topic header
function adi_integrate_display_topic(&$topic_selects, &$topic_tables)
{
$topic_selects = array('mem.id_member', 'mem.avatar', 'mem.email_address', 'COALESCE(lo.log_time, 0) AS is_online', 'a.filename');
$topic_tables = array('LEFT JOIN {db_prefix}log_online AS lo ON (lo.id_member = mem.id_member)', 'LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)');

Pipke

@wylekk

sorry i cannot help you with that at this moment,  it seems the Optimus mod on the mod site isnt compatable with SMF 2.1 yet...
also when i install it with Emulating: 2.0 version i get errors, so i suggest to wait for the next release of the Optimus mod.

Quote from: Bugo on February 14, 2020, 08:30:01 AM
I will realize this feature in the next version of Optimus for SMF 2.1
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

wylekk

After installing the mod avatars disappeared in the notification :(

Type of error: Undefined
8: Undefined index: icon
http://www.sub.wylek.ru/index.php?action=profile;u=1;area=alerts_popup
/home/admin/web/sub.wylek.ru/public_html/Sources/AvatarsDisplayIntegration.php (Line 503)




Pipke

#13
Quote from: wylekk on February 24, 2020, 04:33:56 AM

Type of error: Undefined
8: Undefined index: icon
http://www.sub.wylek.ru/index.php?action=profile;u=1;area=alerts_popup
/home/admin/web/sub.wylek.ru/public_html/Sources/AvatarsDisplayIntegration.php (Line 503)



Thx for finding that, as far my tests go from the screenshot you posted i cannot reproduce that? Can you post all your alerts when the undefined error comes up, need to find out when smf core is not using an alert icon.

Anyway for now, here is the fix for that:

in .../Sources/AvatarsDisplayIntegration.php
Code (find) Select

$context['unread_alerts'][$id_alert]['icon'].= $context['adi']['iconstatus'];


Code (replace by) Select

if (isset($context['unread_alerts'][$id_alert]['icon']))
$context['unread_alerts'][$id_alert]['icon'].= $context['adi']['iconstatus'];
else
$context['unread_alerts'][$id_alert]['icon'] = $context['adi']['iconstatus'];


just wondering how to get an alert for this '{member_link} replied to your unapproved topic, {topic_msg}, in {board_msg}'
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Pipke

Mod updated:

Version 1.1 - Mar 4, 2020
- Added option avatar Who's Online page
- Optimized several css rules
- Fixed css for the 'who likes posts' avatar position
- Fixed comparison operator
- Fixed initial avatar for guests when using bbc @member in posts and at the recent post index

also added languages Russian and Spanish_Latin
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Pipke

Mod updated:

Version 1.2 - Mar 7, 2020
- Fixed anchor bbc @mention member name 'before the @name link'
- Fixed Undefined index: alert icon
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

gecitli

hello thank you for the mod

how to apply this in Recent Posts
http://www.webtiryaki.com
webmaster forumu
Free & Premium Responsive Themes for SMF.

Pipke

Quote from: gecitli on March 13, 2020, 11:21:05 AM
hello thank you for the mod

how to apply this in Recent Posts

thx, glad you like it.
Display avatar poster on the Recent posts index
This option is by default on, you can see it in action on www.your-site/index.php?action=recent

ps.i noticed you have old version of the mod installed, you should upgrade to current v1.2
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Hatshepsut

Hello,

I'm using version 1.2
After installing of Avatars Display Integration, the color of the post numbers in 'Recent post' and in the Search results is changed:

Click =>

The color is very light and there is no contrast, it's harder to view the post number.

Default color, before installing ADI:

Click =>

How to change the light color to some darker, or to default color?

Pipke

@Hatshepsut

you can find that source code in the .../Themes/{YourTheme}/css/AvatarsDisplayIntegration.css file   

find and edit this to your likenings
Code (find) Select

.counter {
    padding-right: 12px;
    line-height: 28px;
    text-shadow: 0 1px 1px #3f3f3f;
    color: #fff;
    opacity: 0.5;
}



or just remove the text-shadow, color and/or opacity rule!
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Advertisement: