This should work:
function max_video_size( $file ) {
$size = $file['size'];
$size = $size / 1024;
$type = $file['type'];
$is_image = strpos( $type, 'video' ) !== false;
$limit = 750;
$limit_output="750kb";
if ( $is_image && $size > $limit ) {
$file['error'] = 'Video files must be smaller than ' . $limit_output;
}
return $file;
}
add_filter( 'wp_handle_upload_prefilter', 'max_video_size' );
Rinse and repeat, changing video in the $is_image line to whatever filetype you want to specify, and even by altering the function, building all desired filetypes into the one filter.
FULL DISCLOSURE = the core of this answer is found in Set limit to media upload?
Related Posts:
- Is there a limit on the number of attachments?
- Resize the WP media Uploader iFrame
- Can I stop wordpress generating media sizes
- Display attachments by the ID of the post being edited in the wp.media frame (frontend)
- How to change format of file link ( Name ) when insert from media uploder
- Efficient way to move media folder to another folder
- wordpress 3.6 media manager cropping timestamp
- WordPress 3.5: Setting custom “full URL path to files” in the Media Library?
- Give users a maximum upload capacity; limit the number of files a user can upload OR limit the number of files per upload
- Media upload finished hook
- How can I batch delete all unattached images with WP-CLI or other automated process?
- Different upload directory based on post type in a theme
- Media not actually deleted on disk when click “Permanent Delete”
- How to wp_upload_bits() to a sub-folder?
- “Add Media” only shows “Full Size” under Attachment Display Settings
- WP 3.5 media manager – how to create a working gallery frame
- What might cause a POST to wp-admin/async-upload.php to return JSON >and< HTML?
- Is it possible to trigger some JavaScript when Media Popup is opened?
- How to call WP3.5 Media Library manager?
- Disable media library tab for non admins in uploader screen
- How to protect uploads in multisite if user is not logged in?
- uploading files to the uploads folder via ftp
- How to get the image url in the input box from media library?
- Remove upload_files capability from a role but allow role to manage an avatar image
- Create custom tab in WordPress 5 media upload
- Restrict file uploads by extension?
- How to Check Disk Space used by Media Library
- How to change the image size in new Media Uploader (ie use medium vs thumbnail)
- Why “Store uploads in this folder” option is not showing in Media Settings in WordPress
- Image uploading stuck on “crunching”
- Add media attachment filter to custom wp.media frame
- Change the size of the image preview on the media edit page
- Add select field to media uploader that adds a class to the image
- WordPress won’t generate image sizes for certain images
- wp.media add context
- wp_enqueue_media() Will not load JS on the theme
- How do I get allowed Media Library upload file extension list?
- Custom “Insert into Post” button
- How to use MediaUpload outside of editor
- Allow only attachment uploaded to current post
- Switch between tabs on “Insert Media” dialog
- Use custom image size in admin panel
- Update image via WP REST API
- Media Library does not show the uploaded image
- Is It Possible to Upload Certain Attachment Files To A Remote Server
- Attach Thumbnail Generated from Video Upload as Featured Image for the Video
- After moving from complete AWS setup to a standalone WordPress Server, Media/Image Files are Broken
- WordPress Media frame pre load images from ids
- Uploading .mp3 files http error – 2 “exact” files one successful other fails
- HTTP Error after finishing uploading a video that is bigger than 64 MB -> After raising the upload limit manually in the wp-config file
- Choosing images size when uploading
- WordPress Media Library showing wrong preview size?
- One step picture upload
- Original image not saving?
- Restrict role to view own media
- How to upload media to specific year/month folder
- upload_max_filesize is set to 64 MB already but WordPress is still showing 2 MB
- PHP error when trying to upload .mp3 files via Media Library [closed]
- Issue with images which have no sizes available
- WordPress media upload issue could not insert attachment into the database
- Organizing uploaded Media in permalink-based folder structure?
- Offload Media Library to other domain on a different server
- Open Media Uploader Link in single post or page
- Remove Media File Items From Server That Do Not Exist in Media Library
- Add SWF file to wordpress through custom template
- How to remove a tab in Media Upload page in wordpress
- Uploaded images result in a file url with full path on disk appended
- Using WP-CLI “wp media import” to sync files to the media library
- Hide media library images from other roles uploaded by admin
- WordPress append -1 to the image name
- Make inline uploader (plupload) on options page upload to a specific folder
- How to display the maximum upload size in a WordPress single site?
- Images not displaying on site or media library
- Replicate Media Galley Edit view in Add Media View
- Front-End Upload media with category
- How to manually set an attachment in a post?
- What is wrong with my wp_insert_attachment code?
- Adding attachment custom field metadata to TinyMCE tag
- Editor User Role can’t see other users media
- Media not displaying other users uploads – WordPress 4.9.2
- Media import failed in the WordPress importer
- Limit attachment caption characters
- Organizing the Media Library for Cleanup
- Allow author to upload image via Media button without plugin
- Insert media while posting is not working with new wordpress update
- Exclude some photos in media library
- Failed to load resource at admin screen
- controlling whether upload is attached to post or not
- Attachment Metadata not updated while uploading audio files
- Media uploader & manager: add/remove class on image with checkbox
- Problem uploading files, after changing domain name
- Image uploaded in media library, can only see it when I using the WP Edit Image feature. 404 when trying to view in browser
- Host Images from Link
- Add frontend editor with media buttons for Visitors and display only their media
- Can’t upload files 1MB+ [closed]
- Unable to upload images using the Media Library
- How can comments be turned off for media attachments on WordPress?
- Question regarding the file path for media_sideload_image and wp_upload_dir()
- How do I restore attachment from files in wp-upload
- Image in binary in the data to WordPress media library