Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Relative URLs and Ckeditor
I'm building a site locally on my PC (XAMPP) which I then want to move onto the server once it's working as required. The wiki rightly suggests that I should use relative URLs. However, ckeditor insists on giving full URLs for inserted images - so they all refer to http://localhost/ which won't work when uploaded to the server.

Is there any way to configure ckeditor (and particularly the "Browse Server" part of loading an image) to use relative URLs? Or do I have to always switch to source view and change the URLs manually?

Thanks for any help.
Try with basehref
Addons: blue business theme, Online Visitors, Notepad
Alternatively, if you know what domain it will run on once you're ready:

go to your hosts file in C:\Windows\System32\drivers\etc\ and add a line like this:


Then install / configure GetSimple with this url and you can still use it while trying it out locally.
When you're ready to upload, remove it from your hosts file and install as normal! Smile
gSvoren Design -
I tried with baseHref, either in gsconfig.php or on the custom config-file

both times it did not work
there are only postings in the ckeditor forum where it does not work
I keep on searching

Das deutschsprachige GetSimple-(Unter-)Forum:
Thanks for the replies. I tried setting baseHref, but it didn't work for me either. So it looks like I'll have to use the hosts file method.
Try with a different approach.
Just do a batch edit of all pages, and change the links inside them.
You can use on of below apps, or search for other batch find->edit file editors

have fun Wink
Addons: blue business theme, Online Visitors, Notepad
I just ran in to this problem too and I finally figured out a reasonable workaround with a little help from this forum post (

in edit.php the default baseHref for CKEditor has been set $SITEURL

The actual problem isn't with CKEditor but with the image browser which resolves the image path separately. What you need to do is change line 23 in filebrowser.php to match the default that is set in edit.php, like so:

previous line 23:
$sitepath = suggest_site_path();

new line 23:
$sitepath = $SITEURL;

Now when I set my site url to '/', I get the correct image links when I drop them in to CKEditor with the browse tool. This saves having to do the tedious batch replace method suggested by yojoe Smile

Edit: And when you do that, any baseHref that you may have added to the CKEditor config file will now be applied as expected since the image url no longer contains
Hello LogicalOctopus,

you are a real nineOpus ;=)

That is a great information you gave us. I will add this to the WIKI / Editor edition and I will describe it in our tipps'n'tricks-section at (referring to your post for sure)

Thanks a lot!

Cheers, Connie

Das deutschsprachige GetSimple-(Unter-)Forum:
I am glad someone found that useful Smile
I tested without success:

$sitepath = $SITEURL;

in gsconfig.php:
define('GSEDITOROPTIONS', "baseHref : '', forceSimpleAmpersand:true,customConfig : '../../../../theme/gs.js',skin: 'v2'
Quote:Now when I set my site url to '/'
where? I think this is my problem ;=(

did I miss something?

Das deutschsprachige GetSimple-(Unter-)Forum:
I think he means in admin/configuration Connie

I test it (just filebrowser.php and my config url in relative in local) and it seems to work when I transfer the test page online (got a relative url on edit and the correct url front-end)

now that might deserve further testing because I didn't update filebrowser.php on my server web, nor I'd had put option on gsconfig.php...
plus the two site are in a folder with the same name and at the same level of their root

I leave you to more testing, I just come here by seeing something about relative url and I knew you could do them with link, so i read and test
Sorry my English is poor, I'm working on it

I think I've cracked this small but important issue with image paths being relative from within CKEDITOR.

The key to this issue was confirmed to me in LogicalOctopus statement.

Quote:The actual problem isn't with CKEditor but with the image browser which resolves the image path separately.

When you select an image after clicking the "Browse Server" button the full URL path was transferred into the image dialog box. CKEDITOR just used whatever was in the box and placed it in the source code.

The solution that I found but may need to be tested by others for confirmation.

Change line 24 of filebrowser.php from

$fullPath = $sitepath . "data/uploads/";


$fullPath = "data/uploads/";

I know line 23 was mentioned but changing line 24 so the $sitepath was omitted completly seemed to work great.

No other changes need to be done to GS. Leave all config files as they are in repsect to baseurl etc.

This solution is not "Upgrade friendly" but it seems to work in both Admin and Frontends of LOCALHOST and Live Domains (and I imagine if GS was installed into a subfolder).

I don't know if there could be a more permanent solution or if there is another reason why $sitepath was added to this line in filebrowser.php. All my testing seems to indicate that having a relavtive path is better than hardcoding the full site's URL in the source code.

I noticed that 3.1 also has this line in filebrowser.php (line 26)

On a sidenote using CKEDITOR with CKFINDER places a relative URL in the Source code which works both in LOCALHOST and the live domain.

Let me know if this works on other peoples environments.

I think moving GS websites around from local PC's, demo locations and Live Domains etc is fairly common and just being able to ZIP up the whole thing an locate it elsewhere fully in-tact without doing a massive Find and Repalce for every image or PDF link could be very handy.
stryker Wrote:Change line 24 of filebrowser.php from

$fullPath = $sitepath . "data/uploads/";


$fullPath = "data/uploads/";

I think this will only work with fancy URLs off, if the path does not start with a slash.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Hi mvlec,

I had the fancy URL's ticked when trying this solution. Just unticked it to see what would happen and still seem to keep the image path intact and image displayed OK in ADMIN and Front end.

Interesting to see if other issue surface though because of this change?
stryker Wrote:I had the fancy URL's ticked when trying this solution.

Does it really work with second level pages with URLs like /parent-page/child-page?
Top level pages won't be a problem.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Still a bit new to GS when it comes to "Parent / Child" pages. Logically looking at it if you had a child page at then having an image path src="data/uploads/image.jpg" wouldn't work so in this scenero it may not be suitable. I tried creating this type of stucture but probably missing something somewhere.

All my pages load from the root directory and I am using the following settings.

Fancy Url's in the settings area as well as the following Permalink structure set as "%slug%.html". I have the following statement in my .htaccess file.

RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]

For my localhost config I also have the following statement in my .htaccess file
RewriteBase /folder/

which I change to "/" when moving to the live domain.

These settings are from the Wiki I believe

I don't know if having a parent / child structure is mainstream but if your pages are just loaded from the root directory then the relative path should work OK.

I'll keep on testing and see if there are any more issues / ramifications because of this change.
Quote:I don't know if having a parent / child structure is mainstream but if your pages are just loaded from the root directory then the relative path should work OK.

your structure is not so unusual ;=) I guess 99% sites use more than one level...

as long as we don't find a way to tell CKeditor the root-directory and it can construct the paths in relation to that absolute URL, you will need absolute paths for the images

you will notice that when you add an internal link in the editor, that link gets translated to an absolute path as well

so you should not waste your time investigating GS, better try to find a solution at ckeditor-website / documentation / forum and if you find a solution, suggestion there, test it and tell us the result

I will be very happy with a working solution, but the clue lies in a configuration of the editor, not in GS

Das deutschsprachige GetSimple-(Unter-)Forum:
It seems to work for me OK but I suppose there are a lot of scenerios where the relative path may not work and I didn't think of internal links that will need to get changed manaully as well.

Will see how it goes and if I come accross anything in CKEDITOR I will comment here.
AFAIK CKEditor inserts the given URL always verbatim, i.e. it doesn't transform the URL as e.g. tinyMCE does depending on the settings for "relative_url", "convert_urls", "remove_script_host" etc. You might check this by transforming the URL returned from the filebrowser manually.

If so, it seems the filebrowser has to be modified. And, without testing, strykers suggestion to remove $sitepath from $fullpath seems reasonable, if this works in admin and normal mode. Probably it should work even if GetSimple is installed to a subfolder of the webroot (perhaps CKEditor's baseHref has to be set accordingly).
Edit: I recommend against doing the following, it's more a hack than anything and it seems to break custom field image paths.

This was annoying me too but I managed to force paths only for both images AND local links.

So instead of
<a href="">Our Team</a>
<img src="">
I get
<a href="/about/team/">Our Team</a>
<img src="/data/uploads/image.jpg">
Unfortunately it involved editing core files (filebrowser.php and template_functions.php) and I'm pretty sure this will only work if your install is a root install (not in a folder). Surely a minor tweak could remedy this though.

Anyway, to fix image paths, in /admin/filebrowser.php
25. --- $sitepath = suggest_site_path();
25. +++ $sitepath = tsl(suggest_site_path(true));
...and to fix links to local pages, in /admin/inc/template_functions.php
726. --- array_push($pageList, array( $dash . $page['title'], find_url($page['url'],$page['parent'])));
726. +++ array_push($pageList, array( $dash . $page['title'], find_url($page['url'],$page['parent'],'abs')));
Modern UI Admin for GetSimple
Watch the demo. Install this plugin. Use this CSS. Enjoy.
Hello my friends,

My question is if anyone, through last years has found a solution for the problem mentioned in this topic ?

I am looking for the best solution, so I would not have to put absolute paths in my img src fields.

Have a nice day...
There is actually another thread on this issue, with solutions, more recent than this.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
There are also some plugins that filter the urls after the fact.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
I think you can use one of these plugins:

Don't know exactly what the difference is, but there's a small description about it on the support forum of ts-fastreplacer:

Maybe this plugin is also relevant:

Users browsing this thread: 1 Guest(s)