Add avatar blog

Go down

Solved Add avatar blog

Post by Fg.Emanuel on March 14th 2018, 7:02 pm

Hello can add the avatar of the user to the blog



for example instead of the image with that computer I would like to add the avatar of the postman

the avatar can be added to the topic, but is it possible on the blog?


I must state that the version of my forum is phpbb2


Last edited by Fg.Emanuel on March 24th 2018, 9:48 am; edited 2 times in total
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by SLGray on March 14th 2018, 9:40 pm

The poster's avatar is already in the blog. 


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

avatar
SLGray
Administrator
Administrator

Male Posts : 43493
Reputation : 3094
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 15th 2018, 6:40 am

mă refer la topic_blog_box
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 16th 2018, 6:23 pm

Can it add?
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Luffy on March 16th 2018, 7:16 pm

I believe you want the avatars to the blog list preview outside the topics. To do that, you'd have to add this Javascript:
Javascript Name: Anything
Placement: In all the pages
Code:
Code:
$(function(){
  var style = document.createElement('STYLE'), css = '.mini_ava2>img{height:20px;margin-right:5px;width:20px;}';
  style.type = 'text/css';
  if (style.styleSheet) style.styleSheet.cssText = css;
  else style.appendChild(document.createTextNode(css));
  document.getElementsByTagName('HEAD')[0].appendChild(style);
   
      if(!window.localStorage) return;
   
      // Default avatar
        var default_avatar= 'https://illiweb.com/fa/invision/pp-blank-thumb.png';
   
      // Time of cache 24h*60m*60s*1000ms - one day
        var caching_time= 24*60*60*1000;
   
      // Time of cache in case of error 60s*1000ms - one minute
        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= {};
   
      $('.blog_comments .span-tab 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);
        };
   
  });
avatar
Luffy
Manager
Manager

Male Posts : 5517
Reputation : 608
Language : Greek, English
Location : Greece

https://www.crossroadz.net

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 17th 2018, 6:43 am

this code does not work.
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 19th 2018, 6:24 am

So it can change ?
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 21st 2018, 4:29 pm

Can it change?
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by SLGray on March 21st 2018, 9:39 pm

Do you have JavaScript Management activated?


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

avatar
SLGray
Administrator
Administrator

Male Posts : 43493
Reputation : 3094
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 22nd 2018, 8:42 am

yes
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 24th 2018, 9:50 am

Can not even find a solution?
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by SLGray on March 24th 2018, 6:59 pm

I will tag @Luffy for you.


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

avatar
SLGray
Administrator
Administrator

Male Posts : 43493
Reputation : 3094
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Add avatar blog

Post by Luffy on March 25th 2018, 11:33 am

Thank you @SLGray for tagging me.

@Fg.Emanuel what is your forum version? Also, can you please send me a link of a blog styled category where guests can view the category in order for me to fix the code for you?

Thanks.
avatar
Luffy
Manager
Manager

Male Posts : 5517
Reputation : 608
Language : Greek, English
Location : Greece

https://www.crossroadz.net

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 25th 2018, 2:34 pm

I gave you a message with all the necessary information
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Luffy on March 25th 2018, 6:40 pm

@Fg.Emanuel

Please don't use bold or color and keep to the default text. This is reserved for the staff for moderation. Thank you.
Please read our forum rules: ESF General Rules

Also could you please answer these questions:
1. Do you have the usernames appear in blog list type view? Or is it only yours?
2. Do you have any other category as blog where the creator is someone other than Emanuel?

Thanks!
avatar
Luffy
Manager
Manager

Male Posts : 5517
Reputation : 608
Language : Greek, English
Location : Greece

https://www.crossroadz.net

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 25th 2018, 8:29 pm

The name appears, depending on who the author of the subject is
I do not have another category
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Luffy on March 25th 2018, 8:33 pm

Okay, add this is your CSS:
Code:
.mini_ava2>img {
  position: absolute;
  margin: 20px 0 0 10px;
  width: 51px;
  height: 51px;
  padding: 3px;
  border-radius: 4px;
}
and then, change the Javascript I posted before to this one:
Code:
$(function(){
  var style = document.createElement('STYLE'), css = '.mini_ava2>img{height:20px;margin-right:5px;width:20px;}';
  style.type = 'text/css';
  if (style.styleSheet) style.styleSheet.cssText = css;
  else style.appendChild(document.createTextNode(css));
  document.getElementsByTagName('HEAD')[0].appendChild(style);
 
      if(!window.localStorage) return;
 
      // Default avatar
        var default_avatar= 'https://illiweb.com/fa/invision/pp-blank-thumb.png';
 
      // Time of cache 24h*60m*60s*1000ms - one day
        var caching_time= 24*60*60*1000;
 
      // Time of cache in case of error 60s*1000ms - one minute
        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= {};
 
      $('.blog .right 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);
        };
 
  });
avatar
Luffy
Manager
Manager

Male Posts : 5517
Reputation : 608
Language : Greek, English
Location : Greece

https://www.crossroadz.net

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 25th 2018, 8:41 pm

Here's how it turns out, there's a demo avatar, the postman's avatar does not appear

avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Luffy on March 25th 2018, 8:43 pm

You have to add the CSS I posted above too! If you did, please add
Code:
!important
at the end of each rule. Thanks!
avatar
Luffy
Manager
Manager

Male Posts : 5517
Reputation : 608
Language : Greek, English
Location : Greece

https://www.crossroadz.net

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 25th 2018, 8:50 pm

I added now
but dc appears that avatar demo, and there is no avatar of the person who wrote the subject, that is, as shown in the picture we were made 2 sample subjects one made with the name emanuel and one with the name cond 2, these two names each a different avatar, and these avatars are not displayed

avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Luffy on March 25th 2018, 8:54 pm

Okay, please remove the above CSS and replace it with this one:
Code:
.blog {
  position: relative;
}
.mini_ava2>img {
  position: absolute;
  margin: 20px 0 0 10px;
  width: 51px;
  height: 51px;
  padding: 3px;
  border-radius: 4px;
  right: 5px;
  background: #ffffff;
}

Note that, this code uses cookies. Therefore, the avatars will appear soon. There is a day's span cookies so apparently, by tomorrow the avatars will display just fine.

You can change that cache time in the javascript here:
Code:
// Time of cache 24h*60m*60s*1000ms - one day
        var caching_time= 24*60*60*1000;
 
      // Time of cache in case of error 60s*1000ms - one minute
        var caching_error= 60*1000;

I'd use 5 minutes to be sure this works and not "brake" the time span. 5 minutes should be like this:
Code:
// Time of cache 24h*60m*60s*1000ms - one day
        var caching_time= 05*60*1000;
 
      // Time of cache in case of error 60s*1000ms - one minute
        var caching_error= 60*1000;
avatar
Luffy
Manager
Manager

Male Posts : 5517
Reputation : 608
Language : Greek, English
Location : Greece

https://www.crossroadz.net

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 25th 2018, 9:09 pm

it still does not work..
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Luffy on March 25th 2018, 9:10 pm

@Fg.Emanuel wrote:it still does not work..
You mean the avatars or the code?
avatar
Luffy
Manager
Manager

Male Posts : 5517
Reputation : 608
Language : Greek, English
Location : Greece

https://www.crossroadz.net

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 25th 2018, 9:12 pm

the avatar appears, but the avatar of the person who posted the subject does not appear
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Luffy on March 25th 2018, 9:17 pm

Yes, I forgot you are using a highly modified theme. Please change the Javascript to this one:
Code:
$(function(){
  var style = document.createElement('STYLE'), css = '.mini_ava2>img{height:20px;margin-right:5px;width:20px;}';
  style.type = 'text/css';
  if (style.styleSheet) style.styleSheet.cssText = css;
  else style.appendChild(document.createTextNode(css));
  document.getElementsByTagName('HEAD')[0].appendChild(style);
 
      if(!window.localStorage) return;
 
      // Default avatar
        var default_avatar= 'https://illiweb.com/fa/invision/pp-blank-thumb.png';
 
      // Time of cache 24h*60m*60s*1000ms - one day, 05m*60s*1000ms - 5 minutes
        var caching_time= 05*60*1000;
 
      // Time of cache in case of error 60s*1000ms - one minute
        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, div#continut .avatar_b img, .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= {};
 
      $('.blog .right 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);
        };
 
  });
avatar
Luffy
Manager
Manager

Male Posts : 5517
Reputation : 608
Language : Greek, English
Location : Greece

https://www.crossroadz.net

Back to top Go down

Solved Re: Add avatar blog

Post by Fg.Emanuel on March 25th 2018, 9:20 pm

Good job man you are the best going!
Thanks for your support, and for your seriousness and commitment to solving the problem!
Can close the topic is considered to be solved!
avatar
Fg.Emanuel
Forumember

Posts : 50
Reputation : 4
Language : Romania

http://www.soft-design.org/forum

Back to top Go down

Solved Re: Add avatar blog

Post by Luffy on March 25th 2018, 9:21 pm

You are welcome! Have a nice day! Smile :rose:

Problem solved & topic archived.
Please read our forum rules: ESF General Rules
avatar
Luffy
Manager
Manager

Male Posts : 5517
Reputation : 608
Language : Greek, English
Location : Greece

https://www.crossroadz.net

Back to top Go down

Back to top


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