MyBB Community Forums

Full Version: Allow avatar randomizers from external URL's
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Why hello there. Big Grin

I hope I'm posting this in the right place. I need help getting a MyBB functionality to work, but it seems like it will require the source code to be edited somehow, so I'm posting it here.

I'm having a problem allowing users to specify image randomizers from external URL's in the Avatar URL field of their profiles. More specifically, when a user tries to set their avatar to a randomizer URL, the page reloads with this error message:

Quote:The following errors were encountered:

The URL you entered for your avatar does not appear to be valid. Please ensure you enter a valid URL.

Here are some of the URL's that various members have attempted to use:

http://fantasyaurora.com/images/randomukschalke.jpg
http://a.random-image.net/bagheera101/spnlolz.jpg
http://a.random-image.net/amusedtodeath/band.jpg

All of these are valid, and they worked correctly on our previous host (ProBoards), but the MyBB system doesn't seem to allow them.

I've done some searching on Google, but I haven't found a suitable solution. If it's possible, I'd like to disable whatever restriction it is that disallows external image randomizers from being entered. The "external" part is important, because I'd like users to be able to modify their own randomizers at any time.

The solutions I came across seemed to require the forum super admin to host the files in a folder themselves, which is problematic because then our users wouldn't be able to update their randomizers without bothering us. Toungue In addition, the codes I've seen only seem to allow for a single randomizer, but as you can see, we'd like to allow multiple randomizers without restriction.

In other words: If a member enters one of the above URL's in their avatar field, I'd like the avatar thing to accept it as their external avatar URL. Plain and simple. I imagine we might have to edit some of the .php files in order to accomplish this; I'm OK with that.


Here are the plugins/themes that are installed on the board and activated:

Quacktacular Themes 1.0
Recent Topics Index Page 1.0.2
Thank You/Like System 1.3.1
Thread Tooltip Preview 1.32
Realize theme

Please note that this error had begun to occur before we installed any of those plugins, so it's unlikely that this problem is caused by a plugin. I'm just including this info for completeness.


Thanks for any assistance. Smile

Got it working! Big Grin

I no longer help in this thread, obviously, but here's the solution in case anyone else comes across this thread looking for it.

1. Create a new custom profile field called "Random avatar URL" for your members to fill in if they'd like to use one. Mine has ID=8, hence the fid8's in the code below.
2. Download and install this plugin: PHP in Templates/Complex Templates
3. Add this code to the postbit template, in place of where the avatar goes:
<if $post['fid8'] then>
<img src="{$post[fid8]}" />
<else>
{$post['useravatar']}
</if>
4. ???
5. Profit!
the samples you provide use redirects with 30x return codes and thus when MyBB saves a local and temporary copy of the image URL provided, its actually saving the webserver response message. Then it tries to get the image information from that text file and it fails.

example: from your second link, the webserver is returning

<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a HREF="http://a.random-image.net/handler.aspx?username=bagheera101&amp;randomizername=spnlolz&amp;random=1309.262">here</a>.</body>

so its not an image that MyBB can work with.
The third URL randomly gives 404 errors and when it yields an image, the http headers claim it's image/Jpeg but MyBB is looking for image/jpeg (lower case). So it's probably the fault of those URLs you are using.