Vinayak Phal
Vinayak Phal

Reputation: 8919

TinyMCE how to append baseURL to LINK and base Path for images

I'm using TinyMCE for Editing my site content.

In Local I've different path for my base url and on development server its different and on production its different.

Is there any way to define the something like baseURL for my links and basePath for Images to be linked.

I want to define baseURL to all my links and basePath to my all the Images.

Right now I'm working on my local and I've created few pages. But when I've thought of dev and production It will be difficult to do the path changing task. Please desperately need some solution.

Upvotes: 4

Views: 1804

Answers (3)

JosephStyons
JosephStyons

Reputation: 58685

I think you will need to set these three options:

relative_urls : false,
remove_script_host : false,
document_base_url : "http://www.example.com/path1/"

According to the TinyMCE documentation, this will convert all relative urls to fully qualified URLs, based on the base you provide.

Screenshot of the relevant TinyMCE documentation

Upvotes: 2

struggleendlessly
struggleendlessly

Reputation: 108

enter image description here

        function myCustomURLConverter(url, node, on_save, name) {
            // Do some custom URL conversion
            if (name == "src")
            {
                url = window.location.origin +"/uploads/" + url
            }
            // Return new URL
            return url;
        }

Upvotes: 1

MalSu
MalSu

Reputation: 541

I'm not sure I undestand the question, but wouldn't this provide what you're looking for?

var base = "http://"+window.location.host;
// base = "http://stackoverflow.com"
var img_base = base + "/img"
// img_base = "http://stackoverflow.com/img"

Upvotes: 0

Related Questions