Forum Discussion

Garywoo's avatar
Garywoo
Guide
10 years ago

Show core avatars larger on messages

The default core avatars for messages is a little small in my opinion at 64x36 px.

 

I've set the Max. Avatar (Message (px)) size to 128x72 px on the skin properties in the studio and custom avatars are showing at that size, however since the core avatars for messages are 64x36 px, they only show at that size. However, the core profile avatar is 128x72 px. How would I go about having that larger image show as the avatar on message posts in topics?

9 Replies

  • Garywoo's avatar
    Garywoo
    Guide
    10 years ago

    VarunGrazitti - I'm pretty sure there isn't a property in the studio or admin to set this either. I've looked high and low.

     

    The first link only describes custom avatars, which are fine in my case, displaying at the proper 128x72 px size. It mentions not to set the avatar width & height in CSS, which i'm not doing as i also don't want to force smaller custom avatars into large blurry messes.

     

    The second link seems to refer to an older version of lithium as the options it talks about don't exist any more (that I could find).

     

    Thanks for the suggestions though.

  • Garywoo's avatar
    Garywoo
    Guide
    10 years ago
    Any help on the custom component to display this larger avatar would be greatly appreciated. I've created some HTML ones, but no FreeMarker ones yet. Is there anywhere where I can find the code for the existing avatar component?
  • luk's avatar
    luk
    Boss
    10 years ago
    Garywoo How do you plan to insert that custom component in the message list (that's what you're talking about right?) without replacing the whole standard component (which is a bad idea, you will lose all menus kudos etc.)?

    If you have a look at the urls for avatars: http://lithosphere.i.lithium.com/t5/image/serverpage/avatar-name/phones/avatar-theme/2delicious/avatar-collection/technology/avatar-display-size/message

    you see that "message" at the end, you can just replace that with "profile", then you'll get a bigger version of the avatar, e.g.

    http://lithosphere.i.lithium.com/t5/image/serverpage/avatar-name/phones/avatar-theme/2delicious/avatar-collection/technology/avatar-display-size/profile

    in your site you'd have to do that via jQuery, basically something like this:

    jQuery('.lia-user-avatar-message').each(function() {

    var $img = $(this);

    $img.attr('src', $img.attr('src').replace('/message', '/profile'));

    });
  • luk I think we'd only have to replace the author component on the forum message layout, but i'm not that confident enough without the existing code for it to replace it yet.

     

    For the meantime, I've used jQuery as you suggested. (tweaked your code to work).

    $('.lia-user-avatar-message').each(function() {
    	var img = $(this);
    	img.attr('src', img.attr('src').replace('/message', '/profile'));
    });

    Any author component help would be appreciated, and the javascript approach has to wait for the page to load, which causes the avatars sizes to 'pop' into their larger sizes as page loads.

  • luk's avatar
    luk
    Boss
    10 years ago
    Garywoo could you maybe make a screenshot of the area/component in question and highlight it there so I get a better idea of what you want to replace?
  • luk

    Here's a screenshot of a forum message and the avatar location. (note: avatar is being enlarged by jQuery script posted above)

     

     

    The studio page component editor looks like this:

    I'm assuming the avatar is part of the 'author' component seen in the main-left column.

     

  • luk's avatar
    luk
    Boss
    10 years ago

    Garywoo I guess you could a) try to override the default author component with @override, e.g. create a component with name author@override (with possible side effects as this cmp probably is used elsewhere, but in this case it's maybe wanted, e.g. same avatar size everywhere) or b) create a completely new custom component.

     

    I think the approach would be somewhat like what's following (ugly...sorry) in order to not lose any information the default component provides:

     

    1) first decide if you want to go with solution path a) or b), I'll go with the @override variant here.

     

    2) then create the component with code similar to this:

    <#-- component with name author@override -->
    <#assign markup>
    	<#-- when using @override on a default component, you can get the original component's content with @delegate
    		 if you choose to create a custom component, you can do the same by adding <@component id="author" /> here,
    		 both approaches could throw an error, so you have to try it out and maybe wrap it in <#attempt><#recover></#attempt>...-->
    	<@delegate>
    </#assign>
    
    <#if markup?has_content>
    	<#assign markup = markup?replace("avatar-display-size/message", "avatar-display-size/profile") />
    
    	${markup}
    </#if>

    what we do here is to basically "fetch" the original markup from the default component and do a search/replace on the image source via FreeMarker's ?replace build-in...yeah, it's horribly ugly...but that's what FreeMarker is =)...not even sure if it works, some default components do not like to get overriden, so if you get an error with @override, try the approach with a custom component...