WP_Customize_Manager::_validate_header_video PHP Method

_validate_header_video() public method

Ensures that the selected video is less than 8MB and provides an error message.
Since: 4.7.0
public _validate_header_video ( WP_Error $validity, mixed $value ) : mixed
$validity WP_Error
$value mixed
return mixed
    public function _validate_header_video($validity, $value)
    {
        $video = get_attached_file(absint($value));
        if ($video) {
            $size = filesize($video);
            if (8 < $size / pow(1024, 2)) {
                // Check whether the size is larger than 8MB.
                $validity->add('size_too_large', __('This video file is too large to use as a header video. Try a shorter video or optimize the compression settings and re-upload a file that is less than 8MB. Or, upload your video to YouTube and link it with the option below.'));
            }
            if ('.mp4' !== substr($video, -4) && '.mov' !== substr($video, -4)) {
                // Check for .mp4 or .mov format, which (assuming h.264 encoding) are the only cross-browser-supported formats.
                $validity->add('invalid_file_type', sprintf(__('Only %1$s or %2$s files may be used for header video. Please convert your video file and try again, or, upload your video to YouTube and link it with the option below.'), '<code>.mp4</code>', '<code>.mov</code>'));
            }
        }
        return $validity;
    }
WP_Customize_Manager