MyBB Community Forums

Full Version: Changing the path of smilies location
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Was looking in the forum for it but didnt find it (or entered the wrong search terms). I am running all pictures off site, on a seperate domain, actually a different machine for scale and speed reasons. Now those little nifty smilies are out there as well (alhtough the page still has its original images folder). Now the smiles it always takes from that standard folder on the old machine. Can be very fast seen when you add one. How can you se tthe default location of the smilies to something else, such as an offsite location?

Thanks a lot for any answer.
Ok, stumbled over the solution: Just give it the FULL path, with http:// etc to the new location, and it works. A bit ugly, but still, it works Smile
You can also alter dosmilies (inside inc/functions_posts.php) to prepend the base URL of your smileys.
Just came across an error in the system with my method.

Lets say the smiley is "biggrin.gif", so the path to it is "/images/smilies/biggrin.gif". Now i change it to "http://img.domain.com/images/smilies/biggrin.gif". In the adminpanels view it all seems fine, it displays it correctly. Now in the problem strikes on actually using it in a post. Say the forum is at "http://forum.domain.com" then the smiley path it generates is "http://forum.domain.com/http://img.domain.com/images/smilies/biggrin.gif". Not really what the plan was Smile

I do not really want to alter code. Not that i lack the skill, but its always a pain to retrace your altered codes once an update comes, so id rather try another solution first.

If there is one..

Looking more deeply into it, is there no option where the path to the images are stored in general? So i could simply set that path and it will adopt it everywhere? IF i have to code it differently, then i will do it extensivly.

Ideal would be using an option in the boards admin panel for that, but i guess i have to dig through the code for that.
well hey

in Admin CP > Message Filters > Smilies Manager > Add

U may there specify the path of the smilies folder , then import them all.


so make ur new directory, and import these smilies from it.


Many regards
Hi, thanks for the reply. I asusme you talk about "Add Multiple Smilies" there. The single smiles adding is what i tried and it did not hold up to the test in reality. As mentioned above, i can see them with the full path in te mnager view, but in the posts it will create that strange url.

The multiple smiles only works on a local system (as it runs through the file system) not on a remote server. There is no setting for the general path of smiles as far as i can see. Looking into hacking that into the code now.
Now that i worked through the code, i got a solution. This works as posted here on MyBB 1.02. If that should be reposted somewhere else, let me know and i will post it.

Add an setting in the control panel, important is simply its name, calling it "imgbaseurl" as this will be in the code below. If you name it different, do so below as well. I decided to make the rule for myself to add the last / so i have to take care of that in the later scripts as well. This is also how the bburl setting is being handled, which is a relative of this setting now. Easiest is adding it to the General Configuration group thats where bburl is.

Now a few details that are important, otherwise the below code will NOT work.

bburl comes without a traling slash, so it will be something like "http://forum.domain.com". The imgbaseurl can be basically two things, one is local like this "images/" or something remote like "http://img.domain.com/". Make sure to include the trailing slash here!

Now for the Smiley manager.
Admin CP > Message Filters > Smilies Manager
Change all the smilies path to reflect something inside the imgbaseurl path. Keep in mind the url is added in front of it, so you have something like "smilies/biggrin.gif" in the smilis manager and it will be "http://img.domain.com/smilies/biggrin.gif" in the end. If you add a slash in front, you get ugly results. Ignore the errors you get from not displaying images, the codes get changed further down for that.

This part makes sure you get the images displayed correctly in posts.

Now open inc/functions_post.php and look for this:
		if($archive == "yes")
		{
			$message = dosmilies($message, $mybb->settings['bburl']);
		}
		else
		{
			$message = dosmilies($message);
		}

Now remove this and replace it with this:
$message = dosmilies($message, $mybb->settings['imgbaseurl']);


Now this part ensures the "clickable smilies" part shows them correctly as well in the post screen.

Open inc/functions.php and find this:
$smilies .= "<td><a href=\"javascript:addsmilie('$find');\"><img src=\"$image\" border=\"0\"></a></td>";

Replace it with this:
					$smilies .= "<td><a href=\"javascript:addsmilie('$find');\"><img src=\"".$mybb->settings['imgbaseurl']."$image\" border=\"0\"></a></td>";

And last but not least this ensures the smiles manager to show them correctly.

Open admin/smilies.php and find this:
		echo "<td class=\"$altbg\" align=\"center\" valign=\"bottom\" nowrap>$smilie[name]<br><br><img src=\"$image\">&nbsp;&nbsp;<b>".stripslashes($smilie[find])."</b><br><br>";

Replace it with this:
		echo "<td class=\"$altbg\" align=\"center\" valign=\"bottom\" nowrap>$smilie[name]<br><br><img src=\"".$mybb->settings['imgbaseurl']."$image\">&nbsp;&nbsp;<b>".stripslashes($smilie[find])."</b><br><br>";

Above that part find this:
		if(strstr($smilie[image], "p://") || substr($smilie[image],0,1) == "/") {
			$image = $smilie[image];
		}
		else
		{
			$image = "../$smilie[image]";
		}

Change it to this:
		$image = $smilie[image];

Save all files, and upload them to the server.