The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

add mini-avater pic to last posts

3 posters

Go down

add mini-avater pic to last posts Empty add mini-avater pic to last posts

Post by ShinGamix 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
ShinGamix
Forumember

Male Posts : 181
Reputation : 3
Language : English

http://shingamix.forumotion.com/

Back to top Go down

add mini-avater pic to last posts Empty Re: add mini-avater pic to last posts

Post by Sir Chivas™ 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://2img.net/i/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™
Sir Chivas™
Helper
Helper

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

https://aforums.org

Back to top Go down

add mini-avater pic to last posts Empty Re: add mini-avater pic to last posts

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

will it still work since it is in french?
ShinGamix
ShinGamix
Forumember

Male Posts : 181
Reputation : 3
Language : English

http://shingamix.forumotion.com/

Back to top Go down

add mini-avater pic to last posts Empty Re: add mini-avater pic to last posts

Post by LGforum 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
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

add mini-avater pic to last posts Empty Re: add mini-avater pic to last posts

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

Sir Chivas care to respond or some mod?
ShinGamix
ShinGamix
Forumember

Male Posts : 181
Reputation : 3
Language : English

http://shingamix.forumotion.com/

Back to top Go down

Back to top

- Similar topics

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