image_make_intermediate_size was not the hook I was looking for, but intermediate_image_sizes_advanced.
Here is a working code:
function disable_upload_sizes( $sizes, $metadata ) {
// Get filetype data.
$filetype = wp_check_filetype($metadata['file']);
// Check if is gif.
if($filetype['type'] == 'image/gif') {
// Unset sizes if file is gif.
$sizes = array();
}
// Return sizes you want to create from image (None if image is gif.)
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'disable_upload_sizes', 10, 2);
Related Posts:
- wp_upload_bits Upload Specific Sizes Only
- Removing Image and Caption Dimension Attributes
- Changing JPEG compression depending on image size
- Change upload directory on custom plugin page
- hook into completed image upload filter
- WP Rest API – Upload media without saving attachment post
- Can I add custom meta for each image uploaded via media-upload.php?
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Rename image uploads with width in filename
- WordPress 3.5+ upload tool filter
- Image size filtering in Media uploader according to custom post type
- Filter to modify post_title after image upload?
- How to check if “media_send_to_editor” is audio?
- Pass parameter to the upload_dir filter
- Allow EPS file upload – two EPS files have different MIME types
- Move a file from a directory to another
- Using wp_handle_upload() to Direct Specific Path by Using $overrides
- Disable auto-resizing of uploaded images, but only for certain filename
- upload_files cap to not loggen in users – add_cap to not logged in users
- Redirect to another page using contact form 7? [closed]
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- Filter causing loss of _wp_attachment_metadata
- Filter Media by attached page or blog post in Library
- How to display a warning when an uploaded image is too small?
- Show uploaded pdf files dynamically and filter by month name
- How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?
- Overriding Generated Attachment Post URL
- List all image sizes still getting disabled sizes
- How to get to the date of the uploaded file
- How to replace all images in all posts and pages with a different size?
- Post Type Upload Directory – {post_type}_upload_dir filter
- can’t output gray scaled image I’ve created using add_image_size
- Rename uploads filenames to POST-ID on upload
- add_filter with specific thumb names
- Dashboard filter based on custom fields URL response code
- The gettext hook doesnt work on text with links
- Problem width wp_insert_post_data and Gutenberg block editor
- How to apply filter on get_the_post_thumbnail()
- Rewrite image links from attachment id to attachment link
- Filter widget_posts_args not working
- User uploads image as “Featured Image” but WordPress resizes it?
- How to filter the source URL of all images on every page
- Hide certain product filters from specific product categories
- Profile image does not upload
- Modify author url display in edit-comments.php
- auth_redirect() doesn’t send users to the page where they orginally tried to acces
- Counting a WP_Post Object value in an arary, using a filter?
- How to add custom media library mime icons?
- Hooked into wp_get_attachment_caption to add content to the default description; not working for jetpack slideshow. Why?
- How to pass a variable between filter/action functions?
- WordPress remove_filter not working
- WordPress append -1 to the image name
- Custom SQL query slows down when using multiple OR … LIKE … in posts_where filter
- How to change an image source when rendering on frontend?
- the_content getting current page content instead specified ID
- How to exclude or include categories in wp rest API without query parameters?
- Filter the title to only affect the_title() template function
- Large uploaded images not resizing?
- Remove and replace woocommerce add to cart button [closed]
- Is it possible to limit number of files a non-admin user can upload via the WordPress media library?
- style_loader_tag not changing stylesheet to preload
- How to change Gallery image url in product page ? In function.php?
- How can I filter the comment action links so that I can display the actions links based on user capabilities?
- Form File Upload Field generates multiple copies of Image Files (different sizes): Is this a WP feature or is this being done by the Plugin
- Redirect an archive page to its relevant URL-friendly filtered page
- Adding link options in insert/edit link dialog window
- cant upload media/pictures to my wordpress site, cant upload anything to my database
- WordPress loading all local images from specific directory?
- unable to write to the database while uploading images
- WordPress Gutenberg core/heading block (wp-block-heading)
- How to redirect a unique link based on login status
- Customising the default wordpress search functionality
- add_filter( ‘the_title’ gets through this if statement twice
- Changing the category for existing Gutenberg blocks
- Filter Post Title without affecting screen-reader-text
- How to modify image caption in posts?
- Extend Nonce Lifetime for Specific Nonce Creation
- Is there a way to auto generate poster image for videos
- Custom sort orderby question
- get_post() with filters applied
- Hook to change the site URL
- Save media files (images) to database instead of the filesystem
- How can I tranlslate post date in italian?
- Run `wp_insert_post_data` on all posts
- How to get title of images in post content
- Upload error on localhost (at minimum, not yet tested online)
- How to generate alt attributes with php / filters?
- WordPress on IIS works except for image upload widget: Win 10 Pro
- How to solve `Error getting remote image` in woocommerce rest api script?
- How to add HTML into error message
- Replace a specific URL on all apperances on the Website (Maybe a filter?)
- Use alternative front page if cookie is set
- “The editor has encountered an unexpected error” After add defer tag to java script
- I want to add string array to this function to filter displayed option in drpodown [closed]
- Recreate the upload folder from a website without having access to the backend/cpanel/filezilla directly from the website
- Trouble with Uploading and Displaying Images
- How to Upload images to a custom folder in upload folder using media uploader
- How to increase media image scale limit?
- How do I check if I can use the allowed_block_types filter?
- Unset image sizes before images are uploaded