- md5
- 10b9427330593d797c84910496951651
- sha1
- 53eaac75f8d497fad929a8bdf347a5cacbb73b76
- sha256
- a7b7072c2816833f96da15a517fba76969e5e9dabc7ce92bde93c429af41d63b
import d from"joomla.dialog";/**
* @copyright (C) 2026 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/if(!window.Joomla)throw new Error("Joomla API is not properly initiated");const{apiBaseUrl:n}=Joomla.getOptions("media-picker-api",{});if(!n)throw new Error('The "media-picker-api" script option is required');const c=i=>{const a=new URL(n,window.location.origin);return a.searchParams.append("task","api.files"),a.searchParams.append("url",!0),a.searchParams.append("path",i.path),a.searchParams.append("mediatypes","0,1,2,3"),a.searchParams.append(Joomla.getOptions("csrf.token"),1),fetch(a,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{if(!e.success||!e.data||!e.data[0]||!e.data[0].url)return null;const l=e.data[0],{rootFull:r}=Joomla.getOptions("system.paths",{}),o=r?l.url.split(r):[l.url];return{url:o.length>1?o[1]:l.url,width:i.width,height:i.height}})};Joomla.editorMediaPicker=(i={})=>new Promise(a=>{const e=i.filetype==="image"?"0":"1,2";Joomla.selectedMediaFile={};let l=!1;const r=t=>{l||(l=!0,a(t))},o=new d({popupType:"iframe",src:`index.php?option=com_media&view=media&tmpl=component&mediatypes=${e}`,textHeader:Joomla.Text._("PLG_IMAGE_BUTTON_IMAGE"),popupButtons:[{label:Joomla.Text._("JSELECT"),className:"button button-success btn btn-success",location:"header",onClick:async()=>{const t=Joomla.selectedMediaFile;let s=null;if(t&&t.path&&t.type==="file")try{s=await c(t)}catch{s=null}r(s),Joomla.selectedMediaFile={},o.close()}},{label:"",ariaLabel:Joomla.Text._("JCLOSE"),className:"button-close btn-close",data:{buttonClose:"",dialogClose:""},location:"header"}]});o.classList.add("joomla-dialog-media-field"),o.addEventListener("joomla-dialog:close",()=>{Joomla.Modal.setCurrent(null),o.destroy(),Joomla.selectedMediaFile={},r(null)}),Joomla.Modal.setCurrent(o),o.show()}),Joomla.editorFilePickers=Joomla.editorFilePickers||{},Joomla.editorFilePickers.image=Joomla.editorMediaPicker,Joomla.editorFilePickers.media=Joomla.editorMediaPicker;
The same content is in 11 releases, Joomla 6.2.0-alpha3 to 6.3.0-alpha1. See them all, or every version of this file.