| 1701 | } |
| 1702 | |
| 1703 | /** |
| 1704 | * Adds an @2x image size for all image sizes registered through add_image_size(). |
| 1705 | * |
| 1706 | * |
| 1707 | */ |
| 1708 | |
| 1709 | function wp_register_2x_image_sizes() { |
| 1710 | if ( ! current_theme_supports( 'high-density-screens' ) ) |
| 1711 | return; |
| 1712 | |
| 1713 | global $_wp_additional_image_sizes; |
| 1714 | $image_sizes = get_intermediate_image_sizes(); |
| 1715 | |
| 1716 | foreach( $image_sizes as $image_size ) { |
| 1717 | |
| 1718 | switch ( $image_size ) { |
| 1719 | case 'large' : |
| 1720 | add_image_size( 'large@2x', intval( get_option( 'large_size_w' ) ) * 2, intval( get_option( 'large_size_h' ) ) * 2, false ); |
| 1721 | break; |
| 1722 | |
| 1723 | case 'medium' : |
| 1724 | add_image_size( 'medium@2x', intval( get_option( 'medium_size_w' ) ) * 2, intval( get_option( 'medium_size_h' ) ) * 2, false ); |
| 1725 | break; |
| 1726 | |
| 1727 | case 'thumbnail' : |
| 1728 | add_image_size( 'thumbnail@2x', intval( get_option( 'thumbnail_size_w' ) ) * 2, intval( get_option( 'thumbnail_size_h' ) ) * 2, true ); |
| 1729 | break; |
| 1730 | |
| 1731 | default : |
| 1732 | add_image_size( $image_size . '@2x', $_wp_additional_image_sizes[ $image_size ]['width'] * 2, $_wp_additional_image_sizes[ $image_size ]['height'] * 2, $_wp_additional_image_sizes[ $image_size ]['crop'] ); |
| 1733 | break; |
| 1734 | } |
| 1735 | |
| 1736 | } |