I’ve always noticed some odd behavior in the MCPUK Resource Browser when it comes to uploading images. First, the window used to have problems refreshing and wouldn’t show any files. This one’s easy to fix. However, after fixing the refresh problem, I noticed that after uploading an image, the darn Edit button wouldn’t work right...kept telling me it couldn’t find the ImageEditor/editor.php file. If I forced a refresh, then it could find the file. So...what do ya do? Couple of simple fixes.
First, the refresh problem. It’s been documented that the MCPUK File Manager can have problems if you use a relative path for the Connector variable. So...all you do is make sure and use a full path instead. All calls to the Resource Browser from any WYSIWYG plugin should be like so:
{$base_url}manager/media/browser/mcpuk/browser.html?Type=images&Connector={$base_url}manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath={$base_url}
Notice the Connector variable uses the {$base_url} parameter and path to the connector file. This will ensure that the connector will refresh properly, especially in Firefox.
You’ll also notice that I added the {$base_url} parameter to the ServerPath variable. I noticed this variable in the main fckconfig.js file and wondered what it was for. What’s odd is that the variable appears nowhere in the code for the Resource Manager. So...I added it in!
Open /manager/media/browser/mcpuk/js/common.js
Around line 57, insert the following line:
oConnector.ServerPath = GetUrlParam( 'ServerPath' ) ;
Changing this alone doesn’t solve the Edit button problem so...now we need to utilize the ServerPath variable in the call to the ImageEditor:
Open /manager/media/browser/mcpuk/frmresourceslist.html
Around line 134, replace:
if(imageEditable==1 && oConnector.ResourceType.toLowerCase()=="images") {
oCell.innerHTML = oCell.innerHTML + '<a href="#" onclick="javascript:window.open(\'../../ImageEditor/editor.php?img=/images' + oConnector.CurrentFolder + fileName + '\',\'win\',\'status=0,toolbar=0\');"><img alt="Edit image" border="0" src="images/editImage.gif" /></a>' ;
}
with:
if(imageEditable==1 && oConnector.ResourceType.toLowerCase()=="images") {
oCell.innerHTML = oCell.innerHTML + '<a href="#" onclick="javascript:window.open(\'' + oConnector.ServerPath + 'manager/media/ImageEditor/editor.php?img=/images' + oConnector.CurrentFolder + fileName + '\',\'win\',\'status=0,toolbar=0\');"><img alt="Edit image" border="0" src="images/editImage.gif" /></a>' ;
}
This should solve the editor button and refresh problems. Ryan, if at all possible, see if you can get these fixes into the new code.
L8R!