Avatar IMG source template variable

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
User avatar
PayBas
Registered User
Posts: 305
Joined: Tue Jul 29, 2008 6:08 pm
Contact:

Avatar IMG source template variable

Post by PayBas »

When making templates, it is often handy to be able to directly use the SRC attribute of the avatar image. This way you can add it much more easily as a "background-image" using CSS. We already do this for many different image, like forum-images, rank-images, etc. but not for avatars.

I know you could do this with javascript, but I think it is a much nicer solution to just let the template output both the formatted IMG element (default), as well as the source. Especially in these places:

viewtopic.php
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
'POSTER_AVATAR_SRC' => $user_cache[$poster_id]['avatar_src'],

memberlist.php
'AVATAR_IMG' => $avatar_img,
'AVATAR_IMG_SRC' => $avatar_img_src,

And there are probably a few more places. It could easily be done by modifying the get_user_avatar function.
User avatar
NORDLANDVOLK
Registered User
Posts: 44
Joined: Thu Oct 14, 2010 8:14 pm
Location: Tracia

Re: Avatar IMG source template variable

Post by NORDLANDVOLK »

PayBas wrote:When making templates, it is often handy to be able to directly use the SRC attribute of the avatar image. This way you can add it much more easily as a "background-image" using CSS. We already do this for many different image, like forum-images, rank-images, etc. but not for avatars.

I know you could do this with javascript, but I think it is a much nicer solution to just let the template output both the formatted IMG element (default), as well as the source. Especially in these places:

viewtopic.php
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
'POSTER_AVATAR_SRC' => $user_cache[$poster_id]['avatar_src'],

memberlist.php
'AVATAR_IMG' => $avatar_img,
'AVATAR_IMG_SRC' => $avatar_img_src,

And there are probably a few more places. It could easily be done by modifying the get_user_avatar function.
include/functions.php(for avatar in header)
viewtopic.php (for FRIST_POST_AVATAR)
viewforum.php (for FRIST_POST_AVATAR)
viewforum.php (for LAST_POST_AVATAR)
And yes it is a good ideea to have more option in function get_user_avatar to use css class or width/height
sorry for my bad english :oops:
User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1875
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: Avatar IMG source template variable

Post by DavidIQ »

I don't really see the benefit in doing this. Maybe you can elaborate a bit more since this doesn't really tell me much:
PayBas wrote:When making templates, it is often handy to be able to directly use the SRC attribute of the avatar image. This way you can add it much more easily as a "background-image" using CSS. We already do this for many different image, like forum-images, rank-images, etc. but not for avatars.
To me it seems much more complicated and cumbersome to throw different user avatars into a stylesheet than it is to directly render an img tag.
Image
User avatar
PayBas
Registered User
Posts: 305
Joined: Tue Jul 29, 2008 6:08 pm
Contact:

Re: Avatar IMG source template variable

Post by PayBas »

DavidIQ wrote:I don't really see the benefit in doing this. Maybe you can elaborate a bit more since this doesn't really tell me much:
PayBas wrote:When making templates, it is often handy to be able to directly use the SRC attribute of the avatar image. This way you can add it much more easily as a "background-image" using CSS. We already do this for many different image, like forum-images, rank-images, etc. but not for avatars.
To me it seems much more complicated and cumbersome to throw different user avatars into a stylesheet than it is to directly render an img tag.
I don't put them in a stylesheet necessarily. I regularly use it like this:

Code: Select all

<div style="background-image: url("avatar_src.jpg");"><div class="some fancy overlay">...</div></div>
I know this could be done with :after selectors, but for backwards-compatibility reasons... I'd rather just use the SRC.
Post Reply