WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up a widget that allows to add an image to a sidebar / widget area.

Basically I have a dropdown that allows the user to select one of the available sizes inside the theme's functions.php file using add_image_size().

Apart from the obvious ( renaming all the add_image_size() ) is there a way to get the size so that I can display that as well as the name?

This is my current drop down code:

    $sizes = get_intermediate_image_sizes();
    $available_size  = '<select name="' . $this->get_field_name('image') . '" >' . "\r\n";
    $available_size .= '<option value="0" selected="selected">Choose</option>' . "\r\n";
    foreach ( $sizes as $size ) {
        if ( $instance['size'] == $size ) :
            $available_size .= '<option value="' . $size . '" selected="selected">' . $size . '</option>' . "\r\n";
        else :
            $available_size .= '<option value="' . $size . '">' . $size . '</option>' . "\r\n";         

    $available_size .= '</select>' . "\r\n";

    echo $available_size;
share|improve this question
up vote 3 down vote accepted
global $_wp_additional_image_sizes;
print '<pre>';
print_r( $_wp_additional_image_sizes );
print '</pre>';
share|improve this answer
Perfect, thanks – Andrew Benbow May 3 '11 at 7:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.