My email application oempro uses Fckeditor to upload and insert the images but the mailings arrive with relative image paths which do not include my domain name.
This is what the email source looks like for the image location:
<img height="88"
src="/emailer/system/data/user_uploads/1/Image/folder1/company_logo.gif" width="200" alt=""/>
This is how it should be:
<img height="88"
src="http://domain.com/emailer/system/data/u ... y_logo.gif" width="200" alt=""/>
This is the piece of code in the fckeditor config.php file which I believe controls the image path:
session_start(); $Config['UserFilesPath'] = $_SESSION['oemPro']['Settings']['DataRelativePath'].'/user_uploads/'.$_SESSION['oemPro']['Administrator']['AdministratorID'].'/';
I also found a file which was included in the latest version of the email application which contains the following code to try to fix this problem but that obviously didn't work when it was created ... maybe somebody can see the flaw in it?
// Fixes FCKEditor image source bug function FixFCKEditorImageSourceBug($Content, $ArrayConfig) { preg_match_all("/src\=\"(.*)\/data\/user_uploads(.*)\"/iU", $Content, $ArrayMatches, PREG_SET_ORDER); foreach ($ArrayMatches as $EachMatch) { $TMPImageURL = $EachMatch[1].'/data/user_uploads'.$EachMatch[2]; $TMPCorrectImageURL = $ArrayConfig['URLs']['Software'].$TMPImageURL; $Content = str_replace('src="'.$TMPImageURL.'"', 'src="'.$TMPCorrectImageURL.'"', $Content); } preg_match_all("/src\=\"(.*)\/data\/editors\/fckeditor(.*)\"/iU", $Content, $ArrayMatches, PREG_SET_ORDER); foreach ($ArrayMatches as $EachMatch) { $TMPImageURL = $EachMatch[1].'/data/editors/fckeditor'.$EachMatch[2]; $TMPCorrectImageURL = $ArrayConfig['URLs']['Software'].$TMPImageURL; $Content = str_replace('src="'.$TMPImageURL.'"', 'src="'.$TMPCorrectImageURL.'"', $Content); } return $Content; }
Any suggestions will be greatly appreciated. Thanks!
RE: Absolute image path problem
Correction in connector.php
It's suppose to be this way..
if(!empty($Config['WebsiteUrl']))
$GLOBALS["WebsiteUrl"] = $Config['WebsiteUrl'];
else
$GLOBALS["WebsiteUrl"] = .'http://'.$_SERVER["SERVER_NAME"];
-----------------------------------------
I don't think it will work with some of you but I hope you get the idea.
RE: Absolute image path problem
Thanks for your help EddyVlad!!
RE: Absolute image path problem
Here's a solution...
ASP, CFM, Perl... users do this on your respective script folder. I'm doing this example in PHP.
First, open your :-
FCKeditor\editor\filemanager\browser\default\connectors\php\config.php
Add these lines :-
$Config['UserFilesFolder'] = 'UserFiles/';
$Config['WebsiteUrl'] = 'http://localhost';
---------------------------------------------------------------------
Secondly, open your :-
FCKeditor\editor\filemanager\browser\default\connectors\php\connector.php
Add these lines below $GLOBALS["UserFilesPath"] .= '/' ;
$GLOBALS["UserFilesFolder"] = $Config['UserFilesFolder'];
if(isset($Config['WebsiteUrl']))
$GLOBALS["WebsiteUrl"] = $Config['WebsiteUrl'];
else
$GLOBALS["WebsiteUrl"] = $_SERVER["SERVER_NAME"];
---------------------------------------------------------------------
Thirdly, Open Your :-
FCKeditor\editor\filemanager\browser\default\connectors\php\io.php
Add this function :-
function GetAbsoluteUrlFromPath( $resourceType, $folderPath )
{
if ( $resourceType == '' )
return RemoveFromEnd( $GLOBALS["WebsiteUrl"], '/' ) . $folderPath ;
else
return RemoveFromEnd( $GLOBALS["WebsiteUrl"], '/' ) . '/' . $GLOBALS["UserFilesFolder"] . $resourceType;
}
---------------------------------------------------------------------
Fourth, open your:-
FCKeditor\editor\filemanager\browser\default\connectors\php\basexml.php
And replace CreateXmlHeader function with this :-
function CreateXmlHeader( $command, $resourceType, $currentFolder )
{
SetXmlHeaders() ;
// Create the XML document header.
echo '<?xml version="1.0" encoding="utf-8" ?>' ;
// Create the main "Connector" node.
echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">' ;
// Add the current folder node.
echo '<CurrentFolder absolute="'.ConvertToXmlAttribute( GetAbsoluteUrlFromPath( $resourceType, $currentFolder ) ).'" path="' . ConvertToXmlAttribute( $currentFolder ) . '" url="' . ConvertToXmlAttribute( GetUrlFromPath( $resourceType, $currentFolder ) ) . '" />' ;
}
---------------------------------------------------------------------
Lastly, Open your :-
FCKeditor\editor\filemanager\browser\default\frmresourceslist.html
Replace the whole function GetFoldersAndFilesCallBack( fckXml ) with this :-
function GetFoldersAndFilesCallBack( fckXml )
{
if ( oConnector.CheckError( fckXml ) != 0 )
return ;
// Get the current folder path.
var oNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' ) ;
var sCurrentFolderPath = oNode.attributes.getNamedItem('path').value ;
var sCurrentFolderUrl = oNode.attributes.getNamedItem('url').value ;
var sCurrentAbsolute = oNode.attributes.getNamedItem('absolute').value + sCurrentFolderPath;
// Add the Folders.
var oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' ) ;
for ( var i = 0 ; i < oNodes.length ; i++ )
{
var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
oListManager.AddFolder( sFolderName, sCurrentFolderPath + sFolderName + "/" ) ;
}
// Add the Files.
var oNodes = fckXml.SelectNodes( 'Connector/Files/File' ) ;
for ( var i = 0 ; i < oNodes.length ; i++ )
{
var sFileName = oNodes[i].attributes.getNamedItem('name').value ;
var sFileSize = oNodes[i].attributes.getNamedItem('size').value ;
oListManager.AddFile( sFileName, sCurrentAbsolute + sFileName, sFileSize ) ;
}
}
---------------------------------------------------------------------
That's all there is to it... in config.php, if you leave it blank, it'll use the current url of your website.
But in case your website is in a subfolder, you have to define your own.
Bye...
Eddy Vlad . com
RE: Absolute image path problem
Thanks!
Jake
RE: Absolute image path problem
Anyone around? Anyone willing to help?
Jake