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.

Avatars in Last Posts displaying as default image.

View previous topic View next topic Go down

Solved Avatars in Last Posts displaying as default image.

Post by Castellana on March 8th 2014, 5:03 pm

Hello! Hello

Yesterday I installed the CSS and JS for displaying the Avatar in the Last Posts box.

I used the instructions here, for phpBB2:
http://help.forumotion.com/t127082-last-post-avatar

Everything is working as it is supposed to but when the page is refreshed, some of the avatars do not load. Instead some of them appear as a gray-default-head avatar.

How can I prevent this from happening?

My forum: http://cvas.forumotion.com/
Forum version: phpBB2

Thanks!

Castellana
Forumember

Female Posts : 282
Reputation : 5
Language : english

http://cvas.forumotion.com/portal

Back to top Go down

Solved Re: Avatars in Last Posts displaying as default image.

Post by Pizza Boi on March 8th 2014, 5:07 pm

Hi Very Happy

Did you try clearing your browser cookies and cache or checked your console for any coding errors?

Regards,
Pizza Boi

Pizza Boi
Hyperactive

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

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: Avatars in Last Posts displaying as default image.

Post by Castellana on March 8th 2014, 5:51 pm

Yes, I definitely cleared my cookies and cache after the first incident, but the problem is it keeps happening. At first, all the avatars display correctly. But if the page is refreshed, then some of the avatars turn into the default one.

What do you mean, check my console for any coding errors? Tell me how to do that.

Thanks!

Castellana
Forumember

Female Posts : 282
Reputation : 5
Language : english

http://cvas.forumotion.com/portal

Back to top Go down

Solved Re: Avatars in Last Posts displaying as default image.

Post by Ange Tuteur on March 8th 2014, 8:25 pm

Hello Castellana,

Try this :
Administration Panel > Modules > HTML & Javascript > Javascript codes management > Create a new script :

Title : What you wish
Placement : In the home page
Paste the following code and save :
Code:
$(function(){
 
  if(!window.localStorage) return;
 
  // Avatar by default
  var default_avatar= 'http://illiweb.com/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);
  };
 
  });

Administration Panel > Display > Pictures and colors > Colors > CSS stylesheet
Code:
.mini_ava{
  float:left;
  }
  .mini_ava img{
  width:40px;
  height:40px;
  margin: 0 5px;
  }

Ange Tuteur
Forumaster

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

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Avatars in Last Posts displaying as default image.

Post by Castellana on March 9th 2014, 1:11 am

Okay, that was scary! *lol*

Now there are TWO mini avatars for each Last Post.

Was I supposed to ADD your codes to what I already had?

Or was I supposed to use your codes to REPLACE the CSS and JS that I had already installed?

Lol

Castellana
Forumember

Female Posts : 282
Reputation : 5
Language : english

http://cvas.forumotion.com/portal

Back to top Go down

Solved Re: Avatars in Last Posts displaying as default image.

Post by Ange Tuteur on March 9th 2014, 1:30 am

You were supposed to replace the old codes.

Ange Tuteur
Forumaster

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

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Avatars in Last Posts displaying as default image.

Post by Castellana on March 9th 2014, 5:59 am

You are the Coding Queen! queen

The problem is solved! I refreshed the page several times in a row as a test and the
avatars are displaying correctly each time.

Thanks! I love you

Castellana
Forumember

Female Posts : 282
Reputation : 5
Language : english

http://cvas.forumotion.com/portal

Back to top Go down

Solved Re: Avatars in Last Posts displaying as default image.

Post by Ange Tuteur on March 9th 2014, 6:17 am

You're welcome I love you

Topic solved and archived

Ange Tuteur
Forumaster

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

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