Skip to content

Instantly share code, notes, and snippets.

@emaildano
Created November 27, 2013 05:45
Show Gist options
  • Save emaildano/7671194 to your computer and use it in GitHub Desktop.
Save emaildano/7671194 to your computer and use it in GitHub Desktop.
List Thumbnail Sizes
<?php function list_thumbnail_sizes(){
global $_wp_additional_image_sizes;
$sizes = array();
foreach( get_intermediate_image_sizes() as $s ){
$sizes[ $s ] = array( 0, 0 );
if( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ){
$sizes[ $s ][0] = get_option( $s . '_size_w' );
$sizes[ $s ][1] = get_option( $s . '_size_h' );
}else{
if( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) )
$sizes[ $s ] = array( $_wp_additional_image_sizes[ $s ]['width'], $_wp_additional_image_sizes[ $s ]['height'], );
}
}
echo '<p>Registered Image Sizes:</p>';
echo '<ul style="list-style:circle inside;">';
foreach( $sizes as $size => $atts ){
echo '<li>' . $size . ' ' . implode( 'x', $atts ) . "</li>\n";
}
echo '</ul>';
} ?>
<?php list_thumbnail_sizes(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment