I am trying to create a custom component for upload mp4 video like image uploading component. Video is uploading and save fine and also show on front cms-page but after the save video will be remove or not showing on backend.

Does anyone know the solution or allow mp4 video upload ?

Here I allow the extension for mp4


public function execute()
    $fieldName = $this->getRequest()->getParam('param_name');
    $fileUploader = $this->uploaderFactory->create(['fileId' => $fieldName]);

    // Set our parameters
    $fileUploader->setAllowedExtensions(['jpeg','jpg','png','gif','mp4', 'pdf']);

    try {
        if (!$fileUploader->checkMimeType(['image/png', 'image/jpeg', 'image/gif', 'image/mp4', 'image/pdf'])) {
            throw new \Magento\Framework\Exception\LocalizedException(__('File validation failed.'));

        $result = $fileUploader->save($this->getUploadDir());
        $baseUrl = $this->_backendUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]);
        $result['id'] = $this->cmsWysiwygImages->idEncode($result['file']);
        $result['url'] = $baseUrl . $this->getFilePath(self::UPLOAD_DIR, $result['file']);
    } catch (\Exception $e) {
        $result = [
            'error' => $e->getMessage(),
            'errorcode' => $e->getCode()
    return $this->resultJsonFactory->create()->setData($result);

and this is Preview.html of custom component

 <div class="pagebuilder-content-type pagebuilder-image type-nested" event="{ 
 mouseover: onMouseOver, mouseout: onMouseOut }, mouseoverBubble: false">
 <render args="getOptions().template" ></render>
 <figure attr="data.main.attributes" ko-style="Object.assign({}, data.main.style(), 
  !data.desktop_image.attributes().src ? {} : {borderStyle: 'none'})" 
   <scope args="getUploader().getUiComponent()">
       <render ></render>
     <video if="getViewportImageData().attributes().src"
        ko-style="getViewportImageData().style" controls>
  • I think this is something related to how the html is parsed if you edit the element again. I have the same issue and similar issues with other fields and the solution was the interplay of the master.html and the content_type/xyz.xml. Maybe this helps a bit Nov 3, 2023 at 12:04


Your Answer

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