Make WordPress Core


Ignore:
Timestamp:
02/08/2014 12:40:15 AM (13 years ago)
Author:
nacin
Message:

Add remove_image_size() and tests for it and has_image_size(), added in [27128].

props mordauk, markoheijnen.
fixes #26768. see #26951.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r27128 r27129  
    182182
    183183/**
    184  * Registers a new image size
     184 * Register a new image size.
    185185 *
    186186 * @since 2.9.0
     187 *
     188 * @param string $name   The image size name.
     189 * @param int    $width  The image's width.
     190 * @param int    $height The image's width.
     191 * @param bool   $width  Whether to crop the image to fit the dimensions. Default false.
    187192 */
    188193function add_image_size( $name, $width = 0, $height = 0, $crop = false ) {
    189194        global $_wp_additional_image_sizes;
    190         $_wp_additional_image_sizes[$name] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => (bool) $crop );
    191 }
    192 
    193 /**
    194  * Check if an image size exists
     195        $_wp_additional_image_sizes[ $name ] = array(
     196                'width'  => absint( $width ),
     197                'height' => absint( $height ),
     198                'crop'   => (bool) $crop,
     199        );
     200}
     201
     202/**
     203 * Check if an image size exists.
    195204 *
    196205 * @since 3.9.0
    197206 *
    198  * @param string $name The image size name.
     207 * @param string $name The image size to check.
    199208 * @return bool True if it exists, false if not.
    200209 */
    … …  
    202211        global $_wp_additional_image_sizes;
    203212
    204         return isset( $_wp_additional_image_sizes[$name] );
     213        return isset( $_wp_additional_image_sizes[ $name ] );
     214}
     215
     216/**
     217 * Remove a new image size.
     218 *
     219 * @since 3.9.0
     220 *
     221 * @param string $name The image size to remove.
     222 * @return bool True on success, false on failure.
     223 */
     224function remove_image_size( $name ) {
     225        global $_wp_additional_image_sizes;
     226
     227        if ( isset( $_wp_additional_image_sizes[ $name ] ) ) {
     228                unset( $_wp_additional_image_sizes[ $name ] );
     229                return true;
     230        }
     231
     232        return false;
    205233}
    206234
Note: See TracChangeset for help on using the changeset viewer.