From d8c63724b2b887fb1e5e6f9950c5e1dadec15ea8 Mon Sep 17 00:00:00 2001 From: Achim Ennenbach Date: Wed, 4 Jul 2018 13:28:45 +0200 Subject: [PATCH] fixes #3051 broken image links The image browser always returns image path relative to admin directory, which doesn't work in case the target is a plugin. Added a check for the target and modify the preview url in case it is a plugin. --- e107_admin/image.php | 4 ++++ e107_web/js/core/mediaManager.js | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/e107_admin/image.php b/e107_admin/image.php index b83f47865..3e7177daf 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -41,6 +41,10 @@ e107::js('core', 'plupload/plupload.full.js', 'jquery', 2); e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery'); e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.min.js', 'jquery', 2); e107::js('core', 'core/mediaManager.js',"jquery",5); +// issue #3051 Preview url is wrong when target page is a plugin +// Using this variable to check for the plugins directory and replace with empty space in case of... +// see mediaManager.js (line ~399ff) +e107::js('inline', 'var e107_plugins_directory = "' . str_replace('../', '', e_PLUGIN) . '";'); e107::wysiwyg(true); /* * CLOSE - GO TO MAIN SCREEN diff --git a/e107_web/js/core/mediaManager.js b/e107_web/js/core/mediaManager.js index c3c048ea3..746564417 100644 --- a/e107_web/js/core/mediaManager.js +++ b/e107_web/js/core/mediaManager.js @@ -395,6 +395,14 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}}; { preview = $htmlHolder.val(); } + + // issue #3051 Preview url is wrong when target page is a plugin + var s = new RegExp('/' + e107_plugins_directory + '[\\w]+/', 'gmi'); + if (window.top.document.URL.match(s)) + { + preview = preview.replace(e107_plugins_directory, ''); + } + } $('div#' + target + "_prev", window.top.document).html(preview); // set new value