image_size_input_fields

The timeline below displays how wordpress function image_size_input_fields has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param WP_Post     $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filters the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param string[] $size_names Array of image size labels keyed by their name. Default values
     *                             include 'Thumbnail', 'Medium', 'Large', and 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    $output = array();
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' === $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' !== $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf('(%d&nbsp;&times;&nbsp;%d)', $downsize[1], $downsize[2]) . '</label>';
        }
        $html .= '</div>';
        $output[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => implode("\n", $output));
}

WordPress Version: 5.6

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param WP_Post     $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filters the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param string[] $size_names Array of image size labels keyed by their name. Default values
     *                             include 'Thumbnail', 'Medium', 'Large', and 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    $out = array();
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' === $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' !== $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf('(%d&nbsp;&times;&nbsp;%d)', $downsize[1], $downsize[2]) . '</label>';
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => implode("\n", $out));
}

WordPress Version: 5.5

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param WP_Post     $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filters the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param string[] $size_names Array of image size labels keyed by their name. Default values
     *                             include 'Thumbnail', 'Medium', 'Large', and 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    $out = array();
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' === $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' !== $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf('(%d&nbsp;&times;&nbsp;%d)', $downsize[1], $downsize[2]) . '</label>';
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}

WordPress Version: 5.4

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filters the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param string[] $size_names Array of image size labels keyed by their name. Default values
     *                             include 'Thumbnail', 'Medium', 'Large', and 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    $out = array();
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' != $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf('(%d&nbsp;&times;&nbsp;%d)', $downsize[1], $downsize[2]) . '</label>';
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}

WordPress Version: 5.1

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filters the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param array $size_names Array of image sizes and their names. Default values
     *                          include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    $out = array();
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' != $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf('(%d&nbsp;&times;&nbsp;%d)', $downsize[1], $downsize[2]) . '</label>';
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}

WordPress Version: 4.6

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filters the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param array $size_names Array of image sizes and their names. Default values
     *                          include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    $out = array();
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' != $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2]) . "</label>";
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}

WordPress Version: 4.2

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filter the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param array $size_names Array of image sizes and their names. Default values
     *                          include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    $out = array();
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' != $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2]) . "</label>";
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}

WordPress Version: 4.1

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filter the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param array $size_names Array of image sizes and their names. Default values
     *                          include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' != $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2]) . "</label>";
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}

WordPress Version: 4.0

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param object $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filter the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param array $size_names Array of image sizes and their names. Default values
     *                          include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' != $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2]) . "</label>";
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}

WordPress Version: 3.9

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param object $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filter the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param array $size_names Array of image sizes and their names. Default values
     *                          include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // if this size is the default but that's not available, don't select it
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' != $size) {
            // if $check is not enabled, default to the first available size that's bigger than a thumbnail
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // only show the dimensions if that choice is available
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2]) . "</label>";
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}

WordPress Version: 3.7

/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param object $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    // get a list of the actual pixel dimensions of each possible intermediate version of this image
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // if this size is the default but that's not available, don't select it
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' != $size) {
            // if $check is not enabled, default to the first available size that's bigger than a thumbnail
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // only show the dimensions if that choice is available
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2]) . "</label>";
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}