wykaz wszystkich rozmiarów zdjęć w WordPress
wykaz wszystkich rozmiarów zdjęć
<?php global $_wp_additional_image_sizes; print '<pre>'; print_r( $_wp_additional_image_sizes ); print '</pre>'; ?> <?php function nws_get_all_image_sizes() { global $_wp_additional_image_sizes; $default_image_sizes = get_intermediate_image_sizes(); foreach ( $default_image_sizes as $size ) { $image_sizes[ $size ][ 'width' ] = intval( get_option( "{$size}_size_w" ) ); $image_sizes[ $size ][ 'height' ] = intval( get_option( "{$size}_size_h" ) ); $image_sizes[ $size ][ 'crop' ] = get_option( "{$size}_crop" ) ? get_option( "{$size}_crop" ) : false; } if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) { $image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes ); } return $image_sizes; } var_dump(nws_get_all_image_sizes()); ?>
usuniecie rozmiaru medium_large
add_filter('intermediate_image_sizes', function($sizes) { return array_diff($sizes, ['medium_large']); });
modyfikacja rozmiaru medium_large
function update_wp_image_sizes() { add_image_size( 'medium_large', 480, 360, ['center', 'top']); } add_action('init', 'update_wp_image_sizes');
usuniecie dowolnego, innego niż medium_large rozmiaru
remove_image_size('1536x1536'); remove_image_size('2048x2048');
usuniecie domyślnych rozmiary obrazów WooCommerce
function remove_wc_image_sizes() { remove_image_size( 'woocommerce_thumbnail' ); remove_image_size( 'woocommerce_single' ); remove_image_size( 'woocommerce_gallery_thumbnail' ); remove_image_size( 'shop_catalog' ); remove_image_size( 'shop_single' ); remove_image_size( 'shop_thumbnail' ); } add_action('init', 'remove_wc_image_sizes');
Wyłączenie funkcji automatycznego skalowania obrazu przez WordPress 5.3+
add_filter( 'big_image_size_threshold', '__return_false' );
dodanie nowego rozmiaru
add_image_size( 'galery-min', 480, 360, ['center', 'top'] ); // Hard crop left top add_image_size( 'medium_large', 768, 0); // Hard crop left top
Hope this helps and happy coding :)