This blog has closed. Sorry!
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:
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.
Sorry, the comment form is closed at this time.
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
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!
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.
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.
ooh this is really a good guide!
i’m trying it now
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!
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:
[…] 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 […]
My avatar has been a big “question mark” for quite some time already…
How did you get myavatar to work with brian threaded comments?
Thanks a million for the fix Spud!