[SPLIT] New Default Avatars

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

[SPLIT] New Default Avatars

Post by Gumboots »

Split from phpBB Ideas topic viewtopic.php?t=2651377 - P_I

I used this ages ago. It's not in phpBB syntax, but the guts of it are obvious and it works like a charm. Just change the variables to match phpBB.

Code: Select all

'. (substr($message['member']['name'],0,1)) . '
That's basically all the PHP that is required to get the "First letter fallback av" content. Everything else is just finding out if they already have an avatar, and setting an appropriate class if they haven't, which phpBB already does anyway.

I've never bothered doing a phpBB version, but it should be a no-brainer for anyone who is interested.
Last edited by P_I on Fri May 31, 2024 12:30 pm, edited 1 time in total.
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
Madalin10
Registered User
Posts: 102
Joined: Wed Jun 18, 2014 2:42 pm
Name: Madalin C.

Re: New Default Avatars

Post by Madalin10 »

Gumboots wrote: Fri May 24, 2024 3:18 am I used this ages ago. It's not in phpBB syntax, but the guts of it are obvious and it works like a charm. Just change the variables to match phpBB.

Code: Select all

'. (substr($message['member']['name'],0,1)) . '
That's basically all the PHP that is required to get the "First letter fallback av" content. Everything else is just finding out if they already have an avatar, and setting an appropriate class if they haven't, which phpBB already does anyway.

I've never bothered doing a phpBB version, but it should be a no-brainer for anyone who is interested.
Also, the first letter avatar can be achieved with CSS & HTML only, but this method works per style rather than being a core functionality.
Image
https://awesome-web.design - I offer phpBB & web design services at fair prices.
User avatar
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

Re: New Default Avatars

Post by Gumboots »

Oh sure, you could do that too. I assume you have used ::first-letter and a few other shenanigans like hidden overflow. That's not difficult, but if it's going to be done in core a basic PHP string chop would make more sense. Or it could be done in Twig syntax in any template (or extension).

Which, come to think of it, I might as well try just for giggles. I assume something like this would do it:

Code: Select all

{{ {postrow.POST_AUTHOR_FULL} |first }}
Brackets are probably wrong but should be easy to sort.

ETA: Basic HTML and CSS implementation, if anyone wants it. :)

Markup:

Code: Select all

<dt class="has-profile-rank no-avatar">
	<div class="avatar-container bung-username-in-here-too">
		Oh hai!
	</div>
	<a href="whatever" style="color: #hexstuff;" class="username-coloured">Oh hai!</a>
</dt>

Code: Select all

.bung-username-in-here-too {
 	width: 1.8rem;
 	height: 1.8rem;
 	overflow: hidden;
 	text-align: center;
 	writing-mode: vertical-rl;
 	text-orientation: upright;
}
.bung-username-in-here-too::first-letter {
	font-size: 1.5rem;
	font-weight: bold;
}
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
cabot
Registered User
Posts: 769
Joined: Sat Jan 07, 2012 4:16 pm

Re: New Default Avatars

Post by cabot »

Gumboots wrote: Thu May 30, 2024 12:24 am Which, come to think of it, I might as well try just for giggles. I assume something like this would do it:
This is the method I use for damaïo but it may require some adjustments depending on the file that is to display the first letter as the avatar, as you can see from this post. ^^
User avatar
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

Re: New Default Avatars

Post by Gumboots »

Image
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
Madalin10
Registered User
Posts: 102
Joined: Wed Jun 18, 2014 2:42 pm
Name: Madalin C.

Re: New Default Avatars

Post by Madalin10 »

Gumboots wrote: Thu May 30, 2024 12:24 am Oh sure, you could do that too. I assume you have used ::first-letter and a few other shenanigans like hidden overflow. That's not difficult, but if it's going to be done in core a basic PHP string chop would make more sense. Or it could be done in Twig syntax in any template (or extension).

Which, come to think of it, I might as well try just for giggles. I assume something like this would do it:
Yes. It also works for the header's photo and memberlist photo. Also if the forumlist avatar ext is installed works there too, but they all require template modification and css.

Also with js is possible to extract the first 2 letters let's say.
https://awesome-web.design - I offer phpBB & web design services at fair prices.
User avatar
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

Re: New Default Avatars

Post by Gumboots »

Sur, but why do it with js when it can be done with just CSS, or with Twig? Using js is possible, but to me it doesn't seem like a good way of doing it. It just becomes another script to process before the page becomes usable.
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦

Return to “phpBB Custom Coding”