2

I have added wyswing editor in my custom module. From there, I want to allow to upload mp4 video from that editor.

How can I do that?

Any one please help me.

2 Answers 2

1

You should override the Storage type using the di.xml. Here is example for PDF. Then upload a new type of media should be possible via storage.

<type name="Magento\Cms\Model\Wysiwyg\Images\Storage">
    <arguments>
        <argument name="extensions" xsi:type="array">
            <item name="allowed" xsi:type="array">
                <item name="jpg" xsi:type="string">image/jpg</item>
                <item name="jpeg" xsi:type="string">image/jpeg</item>
                <item name="png" xsi:type="string">image/png</item>
                <item name="gif" xsi:type="string">image/gif</item>
                <item name="pdf" xsi:type="string">application/pdf</item>
            </item>
            <item name="image_allowed" xsi:type="array">
                <item name="jpg" xsi:type="string">image/jpg</item>
                <item name="jpeg" xsi:type="string">image/jpeg</item>
                <item name="png" xsi:type="string">image/png</item>
                <item name="gif" xsi:type="string">image/gif</item>
                <item name="pdf" xsi:type="string">application/pdf</item>
            </item>
            <item name="media_allowed" xsi:type="array">
                <item name="flv" xsi:type="string">video/x-flv</item>
                <item name="avi" xsi:type="string">video/x-msvideo</item>
                <item name="mov" xsi:type="string">video/x-sgi-movie</item>
                <item name="rm" xsi:type="string">application/vnd.rn-realmedia</item>
                <item name="wmv" xsi:type="string">video/x-ms-wmv</item>
                <item name="pdf" xsi:type="string">application/pdf</item>
            </item>
        </argument>
    </arguments>
</type>
3
  • can you please provide me example of mp4?
    – Niket
    Mar 29, 2021 at 13:27
  • Replace application/pdf with video/mp4 Mar 30, 2021 at 13:05
  • 3
    It's not working.
    – Niket
    Mar 30, 2021 at 17:02
0

Although I haven't done it with the video files, I have done some changes to wysiwyg in a project. Maybe I could guide you to the right direction.

Something to know as of Magento 2.3.x versions the TinyMCE have been upgraded to v4.

First of all you need to extend the TinyMCE, which you can find documentation here

In the plugin for Magento\Cms\Model\Wysiwyg\Gallery\DefaultConfigProvider in the function afterGetConfig you can include your custom configuration, which you can get from TinyMCE documentation. Here is the link for the media config.

1
  • can you please upload example with code?
    – Niket
    Mar 29, 2021 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.