MyBB Community Forums

Full Version: Directory Issues - Displaying Images
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Why didn't I think of that?!

Yes of course direct linking will fix the issue by directly pointing to the directory without having any variable.
Do you have this in your page?

// set the path to your forums directory here (without trailing slash)
$forumdir = "./mybb";

// end editing

$change_dir = "./";

if(!@chdir($forumdir) && !empty($forumdir))
{
	if(@is_dir($forumdir))
	{
		$change_dir = $forumdir;
	}
	else
	{
		die("\$forumdir is invalid!");
	}
}
global $theme;
 $theme['imgdir'] = $forumdir.'/'.substr($theme['imgdir'],0);
Thanks for all the replies. One other thing I should note, is that this custom page is going to be part of a plugin. So setting the image directory to an absolute link in ACP is not going to work as a plugin as opposed to just modifying my own forum to fix that issue.
<img scr="path" />

(2012-08-06, 04:55 PM)ToJ Wrote: [ -> ]
(2012-08-06, 04:50 PM)Ted B Wrote: [ -> ]You can just put an image folder in new folder and put just those images you need in it.

I would use that as a last resort. Not only does it take time to sort all images you're going to need. Copying images simply wastes server space.

He only said a few images as the rest of forum is fine
(2012-08-06, 05:10 PM)Leefish Wrote: [ -> ]Do you have this in your page?

// set the path to your forums directory here (without trailing slash)
$forumdir = "./mybb";

// end editing

$change_dir = "./";

if(!@chdir($forumdir) && !empty($forumdir))
{
	if(@is_dir($forumdir))
	{
		$change_dir = $forumdir;
	}
	else
	{
		die("\$forumdir is invalid!");
	}
}
global $theme;
 $theme['imgdir'] = $forumdir.'/'.$theme['imgdir'];

hey, that looks familiar!

actually if you are always to be using a subfolder in the forum root then using a mix of the above and polarbear's solution is easiest. just global $theme first

global $theme;
if(strpos($theme['imgdir'], '://' === false && substr($theme['imgdir'],0,1) != '/')
{
	$theme['imgdir'] = '../'.$theme['imgdir'];
}

basically if the path is not starting with a protocol (//:) and not already an absolute path (starts with /) then prefix the path with the relative parent (../)
Yes Pavemen, I got it from your portal as home page set up. Sorry for not crediting. Sad

It worked well for me, thank you.
not an issue. the main bit of code is in the portal already by default, my only edit is the theme update.
Pages: 1 2