rounded top
Vote for a site and get traffic to your own, or in other words... be nice for rice!
rounded left rounded right
rounded top
rounded bottom
rounded top

This blog has closed. Sorry!

MyAvatars stack overflow error

April 11th, 2007 by Spud Oregon

A few weeks after setting up this blog, I added the Brian’s Threaded Comments plugin, and soon after that I joined MyBlogLog so I could see the faces of the people coming to this site. It was only natural that I would want to add Napolux’s MyAvatars plugin so that when people comment, their MyBlogLog avatar would show next to what they had written.

Unfortunately, in IE7, whenever I tried to load a page, an error message would pop up saying “Error: Stack Overflow”, and the line number given was where the MyAvatars code was.

I still don’t know why I got the stack overflow error. It’s supposed to occur if there is infinite recursion in your code, but MyAvatars worked fine in Firefox. Anyway, after digging and digging for a solution, there was so little information tying MyAvatars to “stack overflow” errors, that I decided to try and fix it myself, and post about it so if anyone else has the same problem, they can do what I did to fix it.

Open myavatars.php and locate the following near the bottom of the file:

<img class=”MyAvatars” border=”0″ src=”<?php echo $mybloglog_IMG; ?>” onload=” if (this.width > 48) { this.width = 48; this.height = 48; } ; if (this.width < 48) { <?php echo ($gravatar) ? “this.parentNode.href = ‘” . $gravatar_URL . “‘; this.parentNode.title = ‘” . $gravatar_TITLE . “‘; this.src=’” . $gravatar_IMG . “‘;” : “this.parentNode.title = ‘” . $mybloglog_NO_TITLE . “‘;”; if(!$gravatar && $default_IMG != “”)echo ” this.src=’”. $default_IMG .”‘;”;?> this.onload=void(null); }” alt=”MyAvatars 0.2″/>

Replace it with this:

<img class=”MyAvatars” border=”0″ src=”<?php echo $mybloglog_IMG; ?>” height=”48″ width=”48″ alt=”MyAvatars 0.2″/>

That’s it.

I can’t guarantee it will work for everyone. I’m not much of a programmer myself, so I just kept cutting bits out to see if it would help, and I got lucky with this. I’ll assume that by cutting out the references to Gravatar, that comments left by Gravatar users won’t get an avatar added to them. MyBlogLog users should be okay, though.

If anyone has a cleaner fix to this problem, please let me know… and don’t say switch to Firefox! ;)

Rice: Blisslogs is a place to get some blogging tips and learn about my blogging experiences. Views from the cheap seats on the web, technology and the world at large. A blog about online business which aims to help you make and manage your money. Digital sandbox and soapbox  of a software tester. It's not only fruity, it's oaty! Foodie techie. A blog about real estate, travel, money and more Web development services for small and mid-sized business. The blog that puts bob in your bob and weave. A day in the life of an OFW in Singapore! musings of a 20-something neurotic: blogging, reviews, news, fashion, trends Surveys for Australians - and everyone else - that really pay. All legit, reviewed and free to join! My Personal Article Collections An Inuyasha Fan Club! Meditation Music for stress relief Web Design, Web Page Design that is Creative.  Affordable Web Hosting also.

Posted on April 11th, 2007 in Tech Tips.
Comments: 11

Voting has been disabled for all posts since this site's closure on 9/13/2007.


11 Comments

Comment by Napolux
2007-04-11 09:22:56

Well. This is nice solution, but you’re losing the possibility to check for a gravatar.

The stack error is not given by recursion (there’s no recursion in MyAvatars), and the error occurs only in some IE7 installations, not all IE7.

This makes me think of a “single machine’s settings” problem, and not of a plugin problem.

Unluckily on my 2 pc (with IE7) it’s all ok… But I’m working on the problem ;)

Comment by Spud Oregon
2007-04-11 09:53:14

Thanks Napolux. Yeah, I figured I was cutting out gravatar users. Better to have it working for one group than none at all, though.

It’s more of a problem for visitors than site owners. If the site won’t load because of stack overflow errors, they’ll just leave without letting the site owner know what happened. Meanwhile, the webmaster is oblivious to the problem since it all works nicely on his machine. It’s a tricky one!

 
Comment by Matt Huggins
2007-06-05 03:13:32

I just pulled this up for the first time since I don’t have MyAvatars installed and thus never needed to. But anyway, it looks like there actually is potentially recursion depending on certain conditions. I’m really tired right now and so I can’t look into it in too much detail, but the recursion is due to the following:

1. There is an onload event for the image that is triggered when the image loads.
2. The onload script itself has the potential to change the images “src” attribute (where it says “this.src=…”).
3. When the script reloads another image, it triggers a nested onload event within the currently running onload event.

At least this is my understanding of what’s going on that’s causing an issue. The difference between Firefox and IE likely has to do with how events are handled or something like that.

Okay, that’s about all the thinking I can do for one night. Nice quick fix either way. :)

 
 
Comment by Jason Spence
2007-04-11 10:25:36

Switch to firefox! ;-)

Seriously, I’m about to add the MyAvatars plugin to my site. This is good information to have before I give it a go. Thanks for the info.

 
Comment by uncle sha
2007-04-16 20:00:14

ooh this is really a good guide!

i’m trying it now

 
Comment by Chris Chen Subscribed to comments via email
2007-04-26 13:43:25

What does your CSS look like for your avatars? I ask because whenever I get a nested comment, the avatar for only the nested comments (not the original comment) gets all screwy with its alignment. See here for an example.

Any help is much appreciated!

Comment by Spud Oregon
2007-04-26 21:21:26

Hi Chris, looking at your site, I couldn’t find any problem with your nested avatars, so I guess you fixed it, but this is what my css looks like anyhow:

img.MyAvatars
{
float: right;
padding-top: 0px;
padding-left: 8px;
padding-bottom: 6px;
padding-right: 8px;
border-style: none;
}

 
 
2007-05-11 18:32:17

[…] MyAvatars stack overflow error << Nice4Rice - Well. This is nice solution, but you’re losing the possibility to check for a gravatar. The stack error is not given by recursion (there’s no recursion in MyAvatars), and the error occurs only in some IE7 installations, not all IE7. This makes me t […]

 
Comment by Culture Shiok!
2007-05-26 12:07:56

My avatar has been a big “question mark” for quite some time already…

 
Comment by Sire
2007-07-03 23:10:43

How did you get myavatar to work with brian threaded comments?

 
Comment by Supa
2007-09-12 13:07:16

Thanks a million for the fix Spud!

 

Sorry, the comment form is closed at this time.

rounded bottom
rounded top
rounded bottom
rounded top
rounded bottom
rounded top
rounded bottom
rounded bottom