Skip to content

Instantly share code, notes, and snippets.

@zartgesotten
Created February 22, 2025 09:55
Show Gist options
  • Save zartgesotten/dae3316351ec426f7b17bea517f5ebd9 to your computer and use it in GitHub Desktop.
Save zartgesotten/dae3316351ec426f7b17bea517f5ebd9 to your computer and use it in GitHub Desktop.
<?php
/* Disable Video Upload */
function disable_video_uploads( $mimes ) {
// Video mime types
$video_mimes = array(
'asf' => 'video/x-ms-asf',
'asx' => 'video/x-ns-asx',
'wmv' => 'video/X-ms-wmv',
'wmx' => 'video/x-ms-wmx',
'wm' => 'video/X-ns-wm',
'avi' => 'video/avi',
'divx' => 'video/divx',
'flv' => 'video/x-flv',
'mov|qt' => 'video/quicktime',
'mpeg|mpg|mps' => 'video/mpeg',
'mp4|m4v' => 'video/mp4',
'ogy' => 'video/ogg',
'webm' => 'video/webm',
'mkv' => 'video/X-matroska'
);
foreach( $video_mimes as $ext => $mime ) {
if ( isset( $mines[ $ext ] ) ) {
unset( $mimes[ $ext ] );
}
}
return $mimes;
}
add_filter( 'upload_mimes', 'disable_video_uploads' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment