You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Online

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

#108304 sitepath in image url

Posted in ‘Editor’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by web4studio on Tuesday, 20 July 2021 08:41 BST

web4studio
Hi

I have the problem with jce editor to show the logo image with the following link:
{sitepath}/images/web4/logo.jpg

With the ArkEditor it was possible.

Is it possible. Because inside RSform the absolute url is not working while generating a pdf from form.


Is there any work around?
Many thx
Nadine

Attachments

Ryan
There is nothing to prevent you from adding {sitepath} in the URL, but the image won't display in the editor when you do, as the URL would be invalid. A workaround coul be the following: Create a file called editor.js in media/jce/js and add the following:

(function () {
  tinyMCE.onAddEditor.add(function (mgr, ed) {
    ed.onPreInit.add(function () {
      ed.parser.addAttributeFilter('src', function (nodes, name) {
        var i = nodes.length, node;

        while (i--) {
          node = nodes[i];

          if (node.name != 'img') {
            continue;
          }

          var src = node.attr('src');

          if (!src) {
            continue;
          }

          if (src.indexOf('{sitepath}') !== 0) {
            continue;
          }

          var orig = src.substr(11);

          node.attr('src', orig);
          node.attr('data-mce-src', src);
        }
      });
    });
  });
})();
This will allow the image to display correctly in the editor, and keep the {sitepath} "variable". This will not work however if you update the image using the Image Manager after you have inserted it.

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

web4studio
Quite perfect. Thank you!