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.

Avatar in recent topics widget phpbb3

View previous topic View next topic Go down

Solved Avatar in recent topics widget phpbb3

Post by FrOsTyXi on December 9th 2014, 6:08 am

Hello I've seen quite a few topics on this but none have really worked one script only will load a default image from the JavaScript.

If anyone can help me with this that would be awesome!

Thanks in advance.

PHPBB3

Forum Link

FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: Avatar in recent topics widget phpbb3

Post by FrOsTyXi on December 9th 2014, 12:40 pm

bump

FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: Avatar in recent topics widget phpbb3

Post by Ange Tuteur on December 9th 2014, 1:30 pm

Hello Frosty,

Go to Administration Panel > Modules > JavaScript codes management > Create a new script

Title : your choice
Placement : in all the pages
Paste the code below and submit :
Code:
$(function(){
   
      if(!window.localStorage) return;
   
      // Avatar por defecto
        var default_avatar= 'http://illiweb.com/fa/invision/pp-blank-thumb.png';
   
      // Tiempo de cache, aqui 24 h * 60 m * 60 s * 1000 ms entonces un día
        var caching_time= 24*60*60*1000;
   
      // Tiempo de cache de un error, ici 60 s * 1000 ms entonces un minuto
        var caching_error= 60*1000;
   
      var set_avatar= function(id) {
            $('.mini_ava2.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, .frm-set.profile-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= {};
   
      $('#comments_scroll_div a[href^="/u"]').each(function(){
            to_replace[$(this).attr('href').substr(2)]= 1;
            $(this).before('<span class="mini_ava2 member'+$(this).attr('href').substr(2)+'"></span>');
        });
   
      for(i in to_replace)
        {
            set_avatar(i);
        };
   
  });


The go to Display > Colors > CSS stylesheet and paste the rule below into your sheet.
Code:
.mini_ava2 > img {
    height: 20px;
    margin-right: 5px;
    width: 20px;
}

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Avatar in recent topics widget phpbb3

Post by FrOsTyXi on December 9th 2014, 1:38 pm

@AngeTuteur Thank you so much that worked like a charm, and congrats on your promo!!

Topic solved!

FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: Avatar in recent topics widget phpbb3

Post by SLGray on December 9th 2014, 9:32 pm

Topic solved and archived


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 36701
Reputation : 2445
Language : English
Location : United States

http://ztwds.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