Is there a way to add HTML video instead of relying on Youtube, Vimeo, ... It's kinda unprofessional looking and it's not kinda hard to have a video tag that links to URL. Seems like this is supported as a Magento Commerce feature from documentation, I should be able to allow my own CDN link to do this kinda stuff. Seems like a very simple feature left out intentionally which looks bad on an open-source project
2 Answers
You can add a video by edit some code in below plugin
https://github.com/experius/Magento-2-Module-Experius-WysiwygDownloads
You need to add below code in di.xml file, file location etc/adminhtml/di.xml
<item name="mp4" xsi:type="string">video/mp4</item>
For video tag, you need to add below code in this file Controller/Adminhtml/Wysiwyg/Images/OnInsert.php after this line
$image = $helper->getImageHtmlDeclaration($filename, $asIs);
/*Replace mp4 video attribute src to video */
$defaultFileTypes = array('mp4');
foreach($defaultFileTypes as $a){
if (strpos($image, $a) !== false) {
$image= str_replace("img", 'video width="320" height="240" controls', $image);
$image= str_replace("/>", '>', $image);
$image.="</video>";
}
}
-
-
is there a way to do the change in Controller/Adminhtml/Wysiwyg/Images/OnInsert.php in your own theme or module file? that way I need to have the whole file with your snippet added, right?– MKoosejJun 30, 2020 at 8:32
-
-
yes, it's in ./vendor/magento/module-cms/Controller/Adminhtml/Wysiwyg/Images/OnInsert.php , it's not recommended to edit files in vendor files cause composer would replace it– MKoosejJun 30, 2020 at 9:24
-
It's not recommended to host videos on your server as it may consume resources and large storage from your server, this is why even large ecommerce depends on 3rd party video providers to embed required videos. Youtube embedded videos give you the ability to style the embedded video so that you can style it according to your website design
However, if you decide to add videos manually, the easiest way to link videos to products is by using product custom attributes provided by magento, where you will save the video location as a string and call it whenever necessary.
-
does this mean I need to customize the theme to use that string in the video tag?– MKoosejJun 22, 2020 at 8:55