Created
August 1, 2016 07:29
-
-
Save czenzel/0f5888cbbfa4a857e56361dd3bc19b39 to your computer and use it in GitHub Desktop.
Wordpress - Disable Automatic Image Cropping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Disable Automatic Image Crop | |
Author: Wordpress Community | |
Description: wpse124009 - http://wordpress.stackexchange.com/questions/124009/why-wordpress-automatic-cropping-all-my-images and https://developer.wordpress.org/reference/functions/remove_image_size/ | |
*/ | |
add_action( 'init', 'czc_disable_extra_image_sizes' ); | |
add_filter( 'image_resize_dimensions', 'czc_disable_crop', 10, 6 ); | |
function czc_disable_crop( $enable, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) | |
{ | |
// Instantly disable this filter after the first run | |
// remove_filter( current_filter(), __FUNCTION__ ); | |
// return image_resize_dimensions( $orig_w, $orig_h, $dest_w, $dest_h, false ); | |
return false; | |
} | |
function czc_disable_extra_image_sizes() { | |
foreach ( get_intermediate_image_sizes() as $size ) { | |
remove_image_size( $size ); | |
} | |
} | |
?> |
Hi,
Thank you for this snippet. Is there anyway to disable for small images (with W,H dimension <1,024px for example)?
Br,
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's working well on my WP Multisite, just put the file into mu-plugins folder.
Thank you!