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:
<?php
$sizes = get_intermediate_image_sizes();
$available_size = '<select name="' . $this->get_field_name('image') . '" >' . "rn";
$available_size .= '<option value="0" selected="selected">Choose</option>' . "rn";
foreach ( $sizes as $size ) {
if ( $instance['size'] == $size ) :
$available_size .= '<option value="' . $size . '" selected="selected">' . $size . '</option>' . "rn";
else :
$available_size .= '<option value="' . $size . '">' . $size . '</option>' . "rn";
endif;
}
$available_size .= '</select>' . "rn";
echo $available_size;
?>
Get all possible registered image size with their names