add_filter( 'intermediate_image_sizes_advanced', function ( $sizes ) {
$allowed = [ 'thumbnail', 'medium', 'large', 'medium_large' ];
foreach ( $sizes as $name => $size ) {
if ( ! in_array( $name, $allowed ) ) {
unset( $sizes[ $name ] );
}
}
return $sizes;
} );
I ended up setting an array with the crops I would allow and then unset anything that wasn’t there.
Related Posts:
- Attach Thumbnail Generated from Video Upload as Featured Image for the Video
- Original image not saving?
- What is the URL pattern for image thumbnails + sizes?
- Cropping thumbnails to specific dimensions on front end post
- Redimension thumbnail crop without creating new images
- Is there a way to force Featured image to show as attachement?
- Question regarding the file path for media_sideload_image and wp_upload_dir()
- How to Fix HTTP Error When Uploading Images?
- Trigger refresh for new media manager in 3.5
- Physical organization of wordpress media library (Real Media Library plugin)
- No Thumbnails Generated
- Extend Media Library
- How to delete resized (cropped) image uploads and prevent future resizing?
- How to show all available images in WP’s media library when using the Polylang plugin?
- Upload post thumbnail from the front end
- Users can’t upload images on frontend if they haven’t got access to the wp backend
- Why are double-periods (“..”) invalid in a WordPress image filename?
- Password protect some uploaded files, so only logged-in users can view them
- How to protect uploads in multisite if user is not logged in?
- using media uploader to select image of specific size, enforce cropper
- Append button to WordPress Image Details modal
- Change URLs for static content
- Convert uploaded PNG to JPEG automatically
- add_image_size creating lots of images (of various sizes)
- Add new media uploader at frontend for wp 3.5+
- How to disable WordPress Media resize different size version?
- Image uploading stuck on “crunching”
- insert post & Upload post thumbnail from the front end using ajax
- Media library storing files in uploads not folders within in uploads
- Is there a limit on the number of attachments?
- Regenerate thumbnails unexpected resolution (96 x 96)
- How to host different file formats/types for a media attachment without creating multiple attachments?
- Site icons with alpha channel for self-hosted WordPress blog network
- how to use media library [closed]
- Can I stop wordpress generating media sizes
- Replacing Images in Media Library
- How to upload unknown file type?
- Uploading images on front end doesn’t generate thumbnail sizes
- Restrict WordPress Media Library for a specific user role (users can only see/select own media)
- WordPress auto generates small medium and large of an image on upload, how can we guess their links?
- Media Library does not show the uploaded image
- move_uploaded_file() not working on wordpress front end
- Stop WordPress from generating redundant image size
- WordPress 4.9.8 Trying to add filename over image in Media Browser
- Convert (-) and (escape) signs to (_) when uploading files on wordpress media library automatically
- How to get the return value of wp.media({ frame: ‘post’ }) in all cases?
- Uploading .mp3 files http error – 2 “exact” files one successful other fails
- Media library only shows for admin. Doesn’t show editor or below [closed]
- WordPress Uploads Directory not using dates in links
- Upload featured image from front end using media-upload.php
- Restrict role to view own media
- Multi Upload In Theme Options
- Redirect to another page using contact form 7? [closed]
- How to load attachment in media library for current user?
- How To Watermark Audio
- Resize existing library images
- Storing WordPress Media Library Uploaded files onto a separate domain
- Media Library Won’t Display Any Images
- A link (not in the post) to download a specific PDF file
- Issue with images which have no sizes available
- WordPress image crop probems
- More Fields & Media Upload
- Migrating media files (documents only) to a fresh install and maintaining the same directory structure
- How does wordpress handle media files?
- WordPress media upload issue could not insert attachment into the database
- Set different max upload size limits based on file type/extension
- Correctly using the root directory for media uploads?
- Thumbnail images missing in WP media library
- Changing titles in Uploader for “Posts”
- How to detect when a file has been uploaded?
- Cannot upload featured image to a custom post type
- What if I have a large file on the server that I want the wp library to have?
- Multiple images are generated in WP-content in wordpress
- How Do I Change the File Permission For Uploaded Files in WordPress?
- Restrict Users to Only Edit Media Owned by Users in Their Role
- image not display in media library and thumbnail not display in post
- Images uploaded via Gutenberg image block are cropped
- Media Library: Remove replace images of selected author
- How to upload multiple images using WP rest API to media?
- Using Gravity Forms to upload media into library, then attach to post
- Import all media referenced in posts
- How can i link my featured image to be clicked and the file will be downloaded
- Organizing the Media Library for Cleanup
- Allow author to upload image via Media button without plugin
- Featured image to grayscale with PHP imagefilter – which hook to use?
- Issues with WordPress 3.9.6 media libraries on XAMPP
- How to configure WordPress to create thumbnails
- My deleted media exists jet
- Private file system for attachments
- Metabox with file upload to custom directory
- Is it possible to upload multiple images via Media Library tab in Thickbox I’ve created?
- Make thumbnail from uploaded image without plugin
- Set featured link not showing
- wordpress 3.6 media manager cropping timestamp
- Link or button to open the media manager from frontend
- Automatically adding images to a certain page through the Media Uploader
- Host Images from Link
- Bring up the media uploader on click
- Retroactively change Permalinks for media files after disabling year/month format
- Assign multiple categories to Media Library upload