| | 280 | |
| | 281 | /** |
| | 282 | * Gets the width, height, and cropping behaviour of the named image size specified by $size. |
| | 283 | * |
| | 284 | * @see add_image_size() for details on cropping behaviour. |
| | 285 | * |
| | 286 | * @global array $_wp_additional_image_sizes Associative array of additional image sizes. |
| | 287 | * |
| | 288 | * @param string $size A named image size, either built-in or added to WordPress using add_image_size() |
| | 289 | * |
| | 290 | * @return array|bool Associative array with 'width', 'height', and (boolean) crop. These correspond to arguments |
| | 291 | * for add_image_size(); |
| | 292 | */ |
| | 293 | function get_image_size( $size = '' ) { |
| | 294 | |
| | 295 | |
| | 296 | |
| | 297 | $size_atts = false; |
| | 298 | |
| | 299 | if ( in_array( $size, array( 'thumbnail', 'medium', 'large' ) ) ) { |
| | 300 | |
| | 301 | $size_atts = array( |
| | 302 | 'width' => get_option( $size . '_size_w' ), |
| | 303 | 'height' => get_option( $size . '_size_h' ), |
| | 304 | 'crop' => (bool) get_option( $size . '_crop' ) |
| | 305 | ); |
| | 306 | |
| | 307 | } elseif ( has_image_size( $size ) ) { |
| | 308 | |
| | 309 | global $_wp_additional_image_sizes; |
| | 310 | $size_atts = array( |
| | 311 | 'width' => $_wp_additional_image_sizes[ $size ]['width'], |
| | 312 | 'height' => $_wp_additional_image_sizes[ $size ]['height'], |
| | 313 | 'crop' => (bool) $_wp_additional_image_sizes[ $size ]['crop'] |
| | 314 | ); |
| | 315 | } |
| | 316 | |
| | 317 | return $size_atts; |
| | 318 | } |
| | 319 | |
| | 320 | |