The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

add mini-avater pic to last posts

View previous topic View next topic Go down

add mini-avater pic to last posts

Post by ShinGamix on September 17th 2012, 12:48 am

How can I have my forum show a small version of the poster's avatar pic on the latest post column?

ShinGamix
Forumember

Male Posts : 181
Reputation : 3
Language : English

http://shingamix.forumotion.com/

Back to top Go down

Re: add mini-avater pic to last posts

Post by Sir Chivas™ on September 17th 2012, 3:34 am

Hi,

This will be the Javascript: ACP >> Modules >> JavaScript Code management >> Create a new one.
Code:
$ ( function () {
 
    if (! window . localStorage ) return ;
 
    / / Default Avatar
    var Default_avatar = 'http://illiweb.com/fa/invision/pp-blank-thumb.png' ;
 
    / / Time to cache within 24 h 60 m * 60 * s * 1000 ms so one day
    var caching_time = 24 * 60 * 60 * 1000 ;
 
    / / Time of cache error, here 60 s * 1000 ms then one minute
    var caching_error = 60 * 1000 ;
 
    var set_avatar = function ( id ) {
        $ ( '. mini_ava.member' + id ). html ( '<img src = "' + get_avatar ( id ) + "/> ' );
    };
 
    var get_avatar = function ( id ) {
        if(localStorage.getItem('t_ava'+id) < +new Date - caching_time || (localStorage.getItem('d_ava'+id)==default_avatar && localStorage.getItem('t_ava'+id) < +new Date - caching_error))
        {
            localStorage . setItem ( 'd_ava' + id , Default_avatar );
            $ . get ( '/ u' + id , function ( d ) {
                localStorage . setItem ( 't_ava' + id , + new Date );
                localStorage . setItem ( 'd_ava' + id , $ ( '# profile-advanced-right. module: first div img: first,. forumline td.row1.gensmall: first> img,. set.profile-frm-view.left dd img dl.left-box.details: first dd img,. row1 b. gen: first img. real_avatar img ' , d ). first (). attr ( 'src' ) | | Default_avatar );
                set_avatar ( id );
            });
        }
        return localStorage . getItem ( 'd_ava' + id );
    };
 
    var to_replace = {};
 
    $ ( 'strong dd.lastpost a.gensmall,. ipbtable tr td: last-child span a.gensmall strong,. td.tcr strong a.gensmall table,. forumline. row3.over a.gensmall strong' ). each Stock ( function () {
        to_replace [ $ ( this ). attr ( 'href' ). substr ( 2 )] = 1 ;
        $ ( this ). closest ( 'td, dd' ). prepend ( '<div class = "mini_ava member' + $ ( this ). attr ( 'href' ). substr ( 2 ) + "> </ div> ' );
    });
 
    for ( i in to_replace )
    {
        set_avatar ( i );
    };
 
});

Add this into your CSS
Code:
. mini_ava {
  float : left ;
}
. mini_ava img {
  width : 40px ;
  height : 40px ;
  margin : 0 5px ;
  border-radius : 10px ;
  transition : all 2s ;
  -Moz-transition : all 2s ;
  -Webkit-transition : all 2s ;
  -O-transition : all 2s ;
}
. mini_ava img : hover
{
  width : 80px ;
  height : 80px ;
}

Codes from French Support Forum.

Sir Chivas™
Support Moderator
Support Moderator

Male Posts : 6783
Reputation : 430
Language : EN, FR, ES
Location : || CSS || HTML || Graphics Designs || Support ||

Back to top Go down

Re: add mini-avater pic to last posts

Post by ShinGamix on September 22nd 2012, 4:53 am

will it still work since it is in french?

ShinGamix
Forumember

Male Posts : 181
Reputation : 3
Language : English

http://shingamix.forumotion.com/

Back to top Go down

Re: add mini-avater pic to last posts

Post by LGforum on September 22nd 2012, 4:59 am

It won't work at all. Infact, it will serve only to slow down and eventually ruin your forum with constant 'Request Limit Exceeded' messages. Wink
Kudos to the author for caching the avatars.
Forumotion have loosened this limit a little, but still not quite enough to make this plausible using ajax.

LGforum
Hyperactive

Male Posts : 2260
Reputation : 258
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: add mini-avater pic to last posts

Post by ShinGamix on September 22nd 2012, 2:50 pm

Sir Chivas care to respond or some mod?

ShinGamix
Forumember

Male Posts : 181
Reputation : 3
Language : English

http://shingamix.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum