-
Notifications
You must be signed in to change notification settings - Fork 90
Media Gallery Technical Design
Sergii Ivashchenko edited this page Jan 17, 2020
·
1 revision
Meida gallery is operated by lib/web/mage/adminhtml/browser.js that is loading the content using the URL passed to openDialog method from cms_wysiwyg_images_index layout handle. The file also contains the mediabrowser widget declaration.
openDialog: function (url, width, height, title, options)
The \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images\Index controller is adding overlay_popup layout handle and setting storeId to wysiwyg_images.js block
! wysiwyg_images.js block does not exist in the Magento codebase.
\Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content block:
- Adds
typerequest param to contents URL - Uses
target_element_idrequest parameter - Renders mediabrowser configuration json
\Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Tree block:
- Uses
current_tree_pathrequest parameter for tree loader URL - Initializes
folderTreewidget with options
Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content\Uploader block:
- Renders uploader button and js
- Change the requested URL by each element (issue: dependency on configuration)
- Override the
cms_wysiwyg_images_indexlayout (issue: dependency on configuration) - Replace
lib/web/mage/adminhtml/browser.js(Mediabrowserutility) with specific Media Gallery implementation (usage and configuration on element's side)
- Move the
mediabrowserwidget declaration to a separate file fromlib/web/mage/adminhtml/browser.js. Keep themediabrowserreference for loading the widget (inapp/code/Magento/Theme/view/frontend/requirejs-config.js)