Hi, wnoder if anyone can point me in the right direction with image paths in thr editor. I just upgraded to 2.2 and I've messed up my config.
Fck editor is installed in a subdirectory of a sub directory
http://www.mysite.com/develop/admin/FCKeditor
The sites image diretcory is:
http://www.mysite.com/develop/assets
FCKConfig.BaseHref is set to http://www.mysite.com/develop/ in fckconfig.js
If I insert some code to add an image with a relative path - src="assets/myImage.gif" it gives a red x in the editor.
The server logs tell me it gives a 404 for /develop/admin/FCKeditor/editor/assets/myImage.gif
I have confirmed this by setting up a symbolic link from the editor directory back to my sites assets directory, and the images then show.
Is it FCKConfig.BaseHref that's supposed to handle this scenario? I've had this working properly before but I can't find what it was that I did to get in working in my old setup.
Thanks in advance
Ron
Tue, 06/13/2006 - 14:42
#1
RE: FCKConfig.BaseHref and images
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = 'FCKeditor/';
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '400' ;
if ( isset($_GET['Lang']) )
{
$oFCKeditor->Config['AutoDetectLanguage'] = false ;
$oFCKeditor->Config['DefaultLanguage'] = $_GET['Lang'] ;
}
else
{
$oFCKeditor->Config['AutoDetectLanguage'] = true ;
$oFCKeditor->Config['DefaultLanguage'] = 'de' ;
}
$oFCKeditor->Value = 'Hier können Sie Text eingeben und Bilder einfügen.';
$oFCKeditor->Create() ;
in fckconfig.js leave the code as is:
FCKConfig.BaseHref = '' ;
in FCKeditor/editor/filemanager/upload/php/config.php
you can set the path to the directory of the users images.
I did it like this:
// Path to uploaded files relative to the document root.
$dir = $_SESSION['userdir'];
$Config['UserFilesPath'] = '/koeln/UserFiles/'.$dir.'/Image/' ;
The code must end with /Image/ .
Now, when you insert an image, klicking on the Upload-Tab (where two buttons are: "Search" and
"Send it to server") and uploading an image should work correct, the image will be previewed also.
in FCKeditor/editor/filemanager/browser/connectors/default/php/config.php:
allthough the path should be the same, you have to put an other path here:
// SECURITY: You must explicitelly enable this "connector". (Set it to "true").
$Config['Enabled'] = true ;
// Path to user files relative to the document root.
$dir = $_SESSION['userdir'];
$Config['UserFilesPath'] = '/koeln/UserFiles/'.$dir.'/' ;
// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Usefull if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\UserFiles\\' or '/root/mysite/UserFiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = '' ;
if you have php with safe mode = on you'll have to create the directories with ftp as shown in
the other thread.
Hm - I'm not sure if this is what you exactly wanted to know, but I hope it helps somebody somehow.
Greets
Bernd
RE: FCKConfig.BaseHref and images
Dunno. I'm suffering from the same problem. I think I had it working at some point... if you figure it out holler back
Xd
RE: FCKConfig.BaseHref and images
We also would like to get away from using the absolute path (/user123/images/image.gif), and use instead relative (./images/image.gif) which has some technical advantages on our system. However when doing the latter, images do not show up in the editor, which is a problem.
We are currently using a php level workaround at runtime, but wanted to know if there is any way to do it with the configuration file. Trying FCKConfig.BaseHref = '/user123'; or anything similar did not seem to work.
Any ideas?
RE: FCKConfig.BaseHref and images
As the basehref must be a absolute fully qualified URI path, the domain must be included.
So for example if you use only a "/" it won't work with the preview.
Here is a "workaround" I am using:
in fckconfig.js Replace:
FCKConfig.BaseHref = '';
With:
HostList = new Array();
HostList['localhost'] = 'http://localhost/domain.com/www/';
HostList['www.domain.com'] ='http://www.domain.com/';
HostList['other.domain.com'] ='http://other.domain.com/path/';
HostList['secure.domain.com'] ='https://secure.domain.com/';
if(HostList[window.location.host]!=''){
FCKConfig.BaseHref = HostList[window.location.host];
} else {
alert('BaseHref for ' + window.location.host + ' is undefined!');
FCKConfig.BaseHref = '';
}
I hope, that this will help...
SelfMan
RE: FCKConfig.BaseHref and images
Thanks, selfman! I have been stuggling with this for days now, and to know that the BaseHref must be a full URI (that is: begin with http://) helps a lot! I tried your solution, and it works well!
In case you use PHP and don't want to edit your config files, another way to solve the problem is to let PHP figure out the full URI for you. I found the following function helpful.
I found it at
http://blog.taragana.com/index.php/arch ... ndent-way/
but have modified a bit. Originally set the $_SERVER['FULL_URL'] variable to the URL, but now it instead returns the URL as a string.
# FULL_URL uses PHP to create the full URL to the file where the function is called.
# It gives the full url such as http://localhost/user/web/index.php?any ... u&may=have
function fullURL() {
$full_url = 'http';
$script_name = '';
if(isset($_SERVER['REQUEST_URI'])) {
$script_name = $_SERVER['REQUEST_URI'];
} else {
$script_name = $_SERVER['PHP_SELF'];
if($_SERVER['QUERY_STRING']>' ') {
$script_name .= '?'.$_SERVER['QUERY_STRING'];
}
}
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') {
$full_url .= 's';
}
$full_url .= '://';
if($_SERVER['SERVER_PORT']!='80') {
$full_url .=
$_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$script_name;
} else {
$full_url .= $_SERVER['HTTP_HOST'].$script_name;
}
return $full_url;
}
Then, in order to strip the full URL for the last part and just get the path to the folder where the file resides, I created another function:
function getPath($full_URL) {
// removes any appended filename.
// Example: http://www.abc.com/index.html -> http://www.abc.com/
preg_match("/(.*\/)[^\/]*$/", $full_URL, $matches);
return $matches[1];
}
Lastly, when you load the FCKeditor in your PHP file, you just define the BaseHref variable with the help of PHP:
$oFCKeditor = new FCKeditor('content');
$oFCKeditor->BasePath = 'FCKeditor/';
...
$oFCKeditor->Config['BaseHref'] = getPath( fullURL() ); // <-- use the URL functions
...
$oFCKeditor->Create();
RE: FCKConfig.BaseHref and images
RE: FCKConfig.BaseHref and images