News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Hide Avatars from Guests

Started by All Colours Sam, March 04, 2010, 11:00:09 PM

Previous topic - Next topic

All Colours Sam

Link to Mod
Hide Avatars from Guests
by Miss All Sunday



Description Compatibility
2.0
1.1.x


Summary

Hide Avatars from Guests hides all avatars from guests. Members still see avatars.

Installation

Package Manager should work in most cases. the mod now is source edit only, this means it will work with all your themes and there's no need for manual edits.


Support

Questions should be address to the mod support topic.



Changelog

2.0 - 12 January 2011
-rewrite the mod to source only edits, thanks to Arantor for the code.


1.0 - 22 January 2010
First release of Hide Avatars from Guests

Files modified by Hide Avatars from Guests
./Sources/Load.php
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Arantor

#1
Well done, a theme edit and breaks the Look and Layout option to hide avatars.

Better solution would be to modify loadMemberContext, where the avatar is figured out and if either $user_info['id'] or $context['user']['id'] is empty (when in scope), empty the avatar array key. You can't just unset it, though, you do actually have to empty it.

Since I'm nice, here's the RC2 edit.

Code (find) Select
'avatar' => array(
'name' => $profile['avatar'],
'image' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? '<img src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']),
'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])
),


Code (replace) Select
'avatar' => empty($context['user']['id']) ?
array(
'name' => '',
'image' => '',
'href' => '',
'url' => '',
)
:
array(
'name' => $profile['avatar'],
'image' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? '<img src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']),
'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])
),


Slightly ugly edit but does the job in a single line.

EDIT: Corrected typo.
Holder of controversial views, all of which my own.


Matthew K.

Well, I appreciate that. I would prefer a Source edit.

mirahalo

nice one ;)

maybe a nice line of text that says  guest cannot see the avatars?   could be an option also to display a link to either register or login, not in all messages, could be only in the first one ;)

Matthew K.

Thanks for the idea,

I'll definitely consider adding that.
Labradoodle-360
Quote from: 130860 on March 05, 2010, 11:39:25 AM
nice one ;)

maybe a nice line of text that says  guest cannot see the avatars?   could be an option also to display a link to either register or login, not in all messages, could be only in the first one ;)

Sabre™

Nice mod :)

Just adding to Arantors post for those interested, that change is made in the load.php template.
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


Matthew K.

When I update this to RC3, it will go by Sources, rather than template.

Labradoodle-360

Sabre™

Very good mate.
Keep up the good work :)
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


Matthew K.


All Colours Sam

ok, now this mod is updated, will work with 1.1.x and 2.0 RC4  source only edits,  will work with every theme, no settings just install and use,  thanks to Arantor for the code.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Bugo

But what about theme settings for guests?

All Colours Sam

Quote from: Bugo on January 12, 2011, 10:45:47 PM
But what about theme settings for guests?

that is just for display.template.php


this mod works with  loadMemberContext   that means whatever mod or page that uses loadMemberContext  will be affected by his mod, SimplePortal for example uses it, so this mod will work for SimplePortal blocks.

this mod will affect  every page or mod or custom script that uses loadMemberContext and not only display.template
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

All Colours Sam

This mod has been updated to SMF 2.0 and 1.1.x
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

All Colours Sam

Updated for SMF 2.0.x, dropped support for 1.1.x.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

chachin

How can i hide signatures too?

All Colours Sam

I believe there is a separate mod for that.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Dwev

Can you use this Mod also for registered users that don't want to see avatars at all?

The option to not show avatars in SMF turns them into silhouettes, I would like to be able to hide them completely.

Shambles

They can turn it off for themselves in their profile settings.

Dwev

@ Shambles: don't really know what you mean by that.

In our current forum (with custom theme) theme it's indeed possible to choose not to show avatars in the Profile Settings.
But like I wrote, that doesn't hide the avatars completely, it just removes chosen images and still shows a silhouette.

This Mod seems to take care of that, but only for guests.
I was wondering if it's possible to use this mod for registered users as well, maybe though a special permission?

All Colours Sam

/Sources/Load.php find:


'avatar' => empty($context['user']['id']) ?
array(
'name' => '',
'image' => '',
'href' => '',
'url' => '',
)
:
array(
'name' => $profile['avatar'],
'image' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? '<img src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']),
'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])
),


replace with:


'avatar' => $themeID == 0 ?
array(
'name' => '',
'image' => '',
'href' => '',
'url' => '',
)
:
array(
'name' => $profile['avatar'],
'image' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? '<img src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']),
'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])
),




Where $themeID is the var that holds the current theme you are using, can't remember which var is exactly,must be in $theme or $context['current_theme'] or something like that, a var_dump() on $context should give you an idea.

Or replace it with:


'avatar' =>
array(
'name' => '',
'image' => '',
'href' => '',
'url' => '',
),


If you want to get rid of avatars altogether.

Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Advertisement: