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']);
});

usuniecie dowolnego, innego niż medium_large rozmiaru

    remove_image_size('1536x1536');
    remove_image_size('2048x2048');

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

Agnieszka Trefler

Agnieszka Trefler (Ruda) - freelancer, web developer, specjalistka od WordPressa z Wrocławia. Z pasją budowania stron, blogowania i fotografowania. Twórca Inspiracji fotograficznych.