Created
March 5, 2019 01:33
-
-
Save FreshLondon/ab51b33471f081840b12e5f2c0bde4bb to your computer and use it in GitHub Desktop.
Display all available image sizes in WordPress
This file contains hidden or 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
| <? | |
| function _get_all_image_sizes() { | |
| global $_wp_additional_image_sizes; | |
| $default_image_sizes = get_intermediate_image_sizes(); | |
| foreach ( $default_image_sizes as $size ) { | |
| $image_sizes[ $size ][ 'width' ] = intval( get_option( "{$size}_size_w" ) ); | |
| $image_sizes[ $size ][ 'height' ] = intval( get_option( "{$size}_size_h" ) ); | |
| $image_sizes[ $size ][ 'crop' ] = get_option( "{$size}_crop" ) ? get_option( "{$size}_crop" ) : false; | |
| } | |
| if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) { | |
| $image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes ); | |
| } | |
| return $image_sizes; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment