Use a variable with an actual path to a base url to find the actual path to (#8546)

the medialibrary
This commit is contained in:
Matteo Piovanelli 2022-03-17 18:06:46 +01:00 committed by GitHub
parent 88a79cb768
commit ebfd03df0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -17,9 +17,7 @@
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceMediaPicker');
ed.addCommand('mceMediaLibrary', function () {
ed.focus();
var adminIndex = location.href.toLowerCase().indexOf("/admin/");
if (adminIndex === -1) return;
var url = location.href.substr(0, adminIndex) + "/Admin/Orchard.MediaLibrary?dialog=true";
var url = baseOrchardPath + "Admin/Orchard.MediaLibrary?dialog=true";
$.colorbox({
href: url,
iframe: true,

View File

@ -1,4 +1 @@
(function(){tinymce.create("tinymce.plugins.Orchard.MediaLibrary",{init:function(n){n.addCommand("mceMediaLibrary",function(){var t,i;(n.focus(),t=location.href.toLowerCase().indexOf("/admin/"),t!==-1)&&(i=location.href.substr(0,t)+"/Admin/Orchard.MediaLibrary?dialog=true",$.colorbox({href:i,iframe:!0,reposition:!0,width:"90%",height:"90%",onLoad:function(){$("html, body").css("overflow","hidden")},onClosed:function(){var n,r,i,u;if($("html, body").css("overflow",""),n=$.colorbox.selectedData,n!=null){for(r="",i=0;i<n.length;i++)u=location.href.substr(0,t)+"/Admin/Orchard.MediaLibrary/MediaItem/"+n[i].id+"?displayType=Raw",$.ajax({async:!1,type:"GET",url:u,success:function(n){r+=n}});tinyMCE.execCommand("mceReplaceContent",!1,r)}}}))});n.addButton("medialibrary",{icon:"image",title:"Insert media",cmd:"mceMediaLibrary"})},createControl:function(){return null},getInfo:function(){return{longname:"Orchard Media Library Plugin",author:"The Orchard Team",authorurl:"http://orchardproject.net",infourl:"http://orchardproject.net",version:"1.1"}}});tinymce.PluginManager.add("medialibrary",tinymce.plugins.Orchard.MediaLibrary)})();
/*
//# sourceMappingURL=plugin.min.js.map
*/
tinymce.create("tinymce.plugins.Orchard.MediaLibrary",{init:function(ed,url){ed.addCommand("mceMediaLibrary",(function(){ed.focus();var url=baseOrchardPath+"Admin/Orchard.MediaLibrary?dialog=true";$.colorbox({href:url,iframe:!0,reposition:!0,width:"90%",height:"90%",onLoad:function(){$("html, body").css("overflow","hidden")},onClosed:function(){$("html, body").css("overflow","");var selectedData=$.colorbox.selectedData;if(null!=selectedData){for(var newContent="",i=0;i<selectedData.length;i++){var renderMedia=location.href.substr(0,adminIndex)+"/Admin/Orchard.MediaLibrary/MediaItem/"+selectedData[i].id+"?displayType=Raw";$.ajax({async:!1,type:"GET",url:renderMedia,success:function(data){newContent+=data}})}tinyMCE.execCommand("mceReplaceContent",!1,newContent)}}})})),ed.addButton("medialibrary",{icon:"image",title:"Insert media",cmd:"mceMediaLibrary"})},createControl:function(n,cm){return null},getInfo:function(){return{longname:"Orchard Media Library Plugin",author:"The Orchard Team",authorurl:"http://orchardproject.net",infourl:"http://orchardproject.net",version:"1.1"}}}),tinymce.PluginManager.add("medialibrary",tinymce.plugins.Orchard.MediaLibrary);

View File

@ -1,9 +1,14 @@
@using Orchard.ContentManagement
@using Orchard.Environment.Configuration
@using Orchard.Environment.Descriptor.Models
@using Orchard.Localization
@using Orchard.Mvc.Extensions
@{
var shellDescriptor = WorkContext.Resolve<ShellDescriptor>();
var urlPrefix = WorkContext.Resolve<ShellSettings>().RequestUrlPrefix;
if (!string.IsNullOrWhiteSpace(urlPrefix)) {
urlPrefix += "/";
}
}
<script type="text/javascript">
@ -12,6 +17,7 @@
var directionality = "@WorkContext.GetTextDirection((IContent)Model.ContentItem)";
var language = "@Model.Language";
var autofocus = "@(Model.AutoFocus == true ? ViewData.TemplateInfo.GetFullHtmlFieldId("Text") : null)";
var baseOrchardPath = "@Url.MakeAbsolute("/")@urlPrefix";
</script>
@{