Created
April 4, 2014 17:55
-
-
Save twesolowski/9979680 to your computer and use it in GitHub Desktop.
Wordpress - get all defined thumbnail sizes
This file contains 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 | |
function list_thumbnail_sizes() { | |
global $_wp_additional_image_sizes; | |
$sizes = array(); | |
$rSizes = 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'],); | |
} | |
} | |
foreach ($sizes as $size => $atts) { | |
$rSizes[$size] = $size . ' ' . implode('x', $atts); | |
} | |
return $rSizes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much!