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.

change the unknown avatar picture

3 posters

Go down

Solved change the unknown avatar picture

Post by iyaaz March 8th 2014, 12:04 pm

i'm trying to change the unknown avatar picture to an image of my own for some reason it's not changing



Code:
           $(function(){
            
               if(!window.localStorage) return;
            
               // Avatar by default
                var default_avatar= 'http://2img.net/i/fa/invision/pp-blank-thumb.png';
            
               // Time of cache, here : 24hrs * 60m * 60s * 1000ms so one day
                var caching_time= 24*60*60*1000;
            
               // Time of cache in case of error, here : 60s * 1000ms so 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, .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= {};
            
               $('dd.lastpost strong a.gensmall, .ipbtable tr td:last-child span strong a.gensmall, .table td.tcr strong a.gensmall, .forumline .row3.over strong a.gensmall').each(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);
                };
            
           });

PunBB
iyaaz
iyaaz
Forumember

Male Posts : 350
Reputation : 8
Language : English
Location : London

http://iyaaz.forumotion.co.uk/

Back to top Go down

Solved Re: change the unknown avatar picture

Post by Pizza Boi March 8th 2014, 12:28 pm

Hi Very Happy

Why don't you try this instead?

ACP < Display < Avatar Management < Avatars Management < Copy the links and upload the photo for unknown < Make sure you clicked "Define as default avatar"

It would be easier.

Regards,
Pizza Boi
Pizza Boi
Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

Back to top Go down

Solved Re: change the unknown avatar picture

Post by iyaaz March 8th 2014, 1:31 pm

Solved by Pizza Boi, thank you! ----)  :wouhou: 
iyaaz
iyaaz
Forumember

Male Posts : 350
Reputation : 8
Language : English
Location : London

http://iyaaz.forumotion.co.uk/

Back to top Go down

Solved Re: change the unknown avatar picture

Post by Pizza Boi March 8th 2014, 4:46 pm

Hi Very Happy

The pizza's here! That'd be 2.99$ Wink.

No problem~

Regards,
Pizza Boi
Pizza Boi
Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

Back to top Go down

Solved Re: change the unknown avatar picture

Post by SLGray March 8th 2014, 8:10 pm

Problem solved & topic archived.


change the unknown avatar picture Slgray10

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

Male Posts : 51555
Reputation : 3524
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

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