MyBB Community Forums

Full Version: Editor loads smiley images relatively
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Normally this would not be a problem. However I'm building a forum where I've kind of beaten MyBB's URL structure into submission via mod_rewrite and it kind of breaks things being loaded relatively when the page tries to load images from example.com/custompage/addthing/images/smilies/smile.gif (which is not correct). Loading the images from {$mybb->settings['bburl']}/images/smilies/smile.gif (or whatever the JS equivalent is) would fix this due to being an absolute URL.

If for whatever reason this won't be done I'm going to have fun trying to figure out how to hack around this...

On an unrelated note, the means by which I had to do this URL beating is horrible and fragile and belongs on TDWTF but was the only way I could think of to globally format the links for MyBB because there isn't really any other way.
+ one with this issue, embedding MyBB into 3rd party sites is difficult here.
Also note loading relatively means the CDN settings aren't used. 1.8 has a new variable under $mybb->asset_url to handle this which should be used.
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/1291

Thanks for contributing to MyBB!

Regards,
The MyBB Group
Does the [Pushed] prefix mean the issue was pushed to github, or the fix? Confused because I thought to add it, then thought better of it...
just pushed, not fixed... but feel free to pull a fix
Oh I just meant for the title. I haven't the foggiest where to start with fixing SCeditor...
SCEditor is using $dropdownsmilies, $moresmilies and $hiddensmilies, so I'd say changing


if($i < $mybb->settings['smilieinsertertot'])
{
$dropdownsmilies .= '"'.$find.'": "'.$image.'",';
}
else
{
$moresmilies .= '"'.$find.'": "'.$image.'",';
}
for($j = 1; $j < $finds_count; ++$j)
{
$find = htmlspecialchars_uni($finds[$j]);
$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}

to

if($i < $mybb->settings['smilieinsertertot'])
{
	$dropdownsmilies .= '"'.$find.'": "'.$mybb->asset_url.'/'.$image.'",';
}
else
{
	$moresmilies .= '"'.$find.'": "'.$mybb->asset_url.'/'.$image.'",';
}
for($j = 1; $j < $finds_count; ++$j)
{
	$find = htmlspecialchars_uni($finds[$j]);
	$hiddensmilies .= '"'.$find.'": "'.$mybb->asset_url.'/'.$image.'",';
}


in functions.php should give the absolute URL for the smilies.
Would be better to use the get_asset_url() function in that case as it handles things such as links to external sites.
Fixed in #1492.