I create a new widget and one of the parameters is a picture chooser, I just use this https://gist.github.com/cedricblondeau/6174911fb4bba6cb4943 code.
Now I have 2 problems:
1- Insert widget on a page
Everthing looks well. I can open media folder and choose the picture I want to use. When I choose the picture, the picture field on the form, is filled with this value:http://local.magento.com/admin/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvcHVycG...
But when I save the widget data on the page, the picture fied has this value: {{media url=
nothing more. How can I solve this?
2 - Insert the custom widget in a widget (Content > Widget > Add Widget)
When I press the button "Choose image" I have a javascript error: (index):1428 Uncaught ReferenceError: MediabrowserUtility is not defined
Can anyone help me?
Thank you in advance
Having the same issue.
It would be super cool if someone from the Magento team could advise on how to fix this, or provide their own solution.
Having an image chooser in widgets seems like such basic functionality, and there is currently no solution that is working
As for your first question:
I had the same issue. In my case it turned out it had to do something with double double quotes.
https://community.magento.com/t5/Programming-Questions/Custom-widget-with-image-chooser/m-p/37281
Seems to me like an issue with the default widgets.
About the "1428 Uncaught ReferenceError: MediabrowserUtility is not defined".
In my case, was missing some page resources.
To solve, follow these steps:
1) Create a layout update inside your module for the desired handle (in my case adminhtml_widget_instance_edit).
File: app/code/Vendor/Module/view/adminhtml/layout/adminhtml_widget_instance_edit.xml
With content:
<?xml version="1.0"?> <!-- /** * Copyright © 2013-2017 Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <update handle="styles"/> <update handle="editor"/> </page>
2) Flush caches and done!
Add adminhtml_widget_instance_edit.xml file in view/adminhtml/layout folder with below code
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" layout="admin-2columns-left"> <update handle="styles"/> <update handle="editor"/> </page>
`layout="admin-2columns-left"` is added additional to previous answer as otherwise it will show a blank page