Skip Navigation

[Resolved] Webm is not validated as a video in Toolset Types Video field

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 4 replies, has 2 voices.

Last updated by Christian Cox 1 month, 2 weeks ago.

Assigned support staff: Christian Cox.

Author
Posts
#2125165

I am trying to add a webm video to a Video field added via Toolset Types. This field has 'Validate this field' checked. WordPress can handle webm videos (https://wordpress.org/support/article/video-shortcode/) and I can remember that Types too (I did this in other projects).

#2125351

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Screen Shot 2021-07-26 at 9.31.05 AM.png

Hello, I understand you are having trouble uploading a .webm file in a Types video field, is that correct? I ran a quick test in my local test site and I was not able to replicate this problem - a .webm file is saved successfully in a video field in the post editor screen in wp-admin. Can you provide a bit more detail about the problem you experienced?
- Are you trying to upload the video in the post editor screen in wp-admin, or using a front-end Form? If it is in the post editor screen, is this post type edited in the Block Editor or the Classic editor?
- Can you provide a screenshot of the error or validation message shown when you attempt to upload the video? Please include as much of the page as possible in the screenshot.
- If you temporarily deactivate all 3rd-party plugins except Types, temporarily deactivate all custom code snippets in Toolset > Setting > Custom Code, and temporarily activate a default theme like Twenty Twenty One, is the problem still reproducible? If not, please reactivate your theme, code snippets, and other plugins one by one, testing each time, until the problem returns. Let me know if one component causes the error message to return.
- You mentioned that "Validate this field" is checked, but I don't have this same option available for Video fields. See the screenshot here. The only validation available for this field is whether or not the field is required. Can you show me a screenshot of the validation option you mentioned?

#2126165
Screenshot 2021-07-27 at 09.53.21.png
Screenshot 2021-07-27 at 09.52.34.png
Screenshot 2021-07-27 at 09.19.19.png

- Are you trying to upload the video in the post editor screen in wp-admin, or using a front-end Form? If it is in the post editor screen, is this post type edited in the Block Editor or the Classic editor?

I'm using only Types and I'm editing in Gutenberg. I use the field in a PHP template. I have uploaded the video from the upload button without any problems. WordPress displays the video correctly in preview. The video link is added correctly, but when I try to save the post, I get the following error: "You can only add video" (in spanish)

- If you temporarily deactivate all 3rd-party plugins except Types, temporarily deactivate all custom code snippets in Toolset > Setting > Custom Code, and temporarily activate a default theme like Twenty Twenty One, is the problem still reproducible? If not, please reactivate your theme, code snippets, and other plugins one by one, testing each time, until the problem returns. Let me know if one component causes the error message to return.

Yes, I tried that but nothing happens. Still can't save the post... I tried Twenty Twenty One and disable all plugins but still happens.

- You mentioned that "Validate this field" is checked, but I don't have this same option available for Video fields. See the screenshot here. The only validation available for this field is whether or not the field is required. Can you show me a screenshot of the validation option you mentioned?

Sorry about that. I have confused 'Validation' as 'video validation', but the option is 'Required'. (I was thinking in other field like Validation: URL checkbox in URL field, it was a lapsus).

-----

I have the same settings as your screenshot but I can't save the post... It's a bit strange... I change the language to English to show you the original messages.

I have multiple video fields: mp4 and webm. MP4 saves without a problem, but webm is giving me this headache.

#2127125

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Screen Shot 2021-07-27 at 3.03.43 PM.png

Okay based on your information I tried another test in a brand new site, and I was able to see the problem as you described it in the new site. So I spent some time trying to sort out why it works in one site and not another, and it turns out that I was able to work around the problem in two different ways:
- Add a post reference field to the same field group, and place it ABOVE the video field. This seems to have some effect on the validation of the video field in this case. Can you try the same workaround in your site? Please add a Post Reference field temporarily as a test, select any other post type in the reference field settings, then drag the reference field so it is ABOVE the video field in the field group (screenshot attached), and let me know if you are then able to save .webm files in your video field.
- The legacy post editor does not seem to experience the same validation problem as the Block Editor, so this may be why the webm files worked in the past but do not seem to work now.

#2127755

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

My 2nd tier support team also notes that a filter is available to extend the Video field support for various file types. Instead of the previous workaround I mentioned, you can add this filter in your child theme's functions.php file, or you can create a new snippet in Toolset > Settings > Custom Code and append the following code:

/*
 * ALLOW WEBM VIDEO FILE FORMAT IN TYPES VIDEO FIELD
 * Enable support for .webm video files, which are blocked by default
 * Toolset support reference: https://toolset.com/forums/topic/webm-is-not-validated-as-a-video-in-toolset-types-video-field/
 */
add_filter( 'toolset_valid_video_extentions', 'ts_add_webm_extension' );
function ts_add_webm_extension( $ext ){

    $ext[] = 'webm';

    return $ext;
}

If you use the Toolset snippet feature, set the snippet to run everywhere and activate it.