I understand how to make use of add_image_size in PHP to join up a brand new size which may be utilized in templates. It can make images within this size, too when they are submitted.

The dimensions I added like this do not show within the admin, though.

So 2 questions...

  • How do i obtain the image dimensions which i make display in the 'upload image' factor when writers create a new publish?

  • It is possible to method to list it within the admin therefore the writers can also add brand new ones without needing to change PHP code?

Or shall we be held doing a problem, like not putting the add_image_size get in touch with the best placeOrdocument? Are dimensions such as this designed to display in the upload menu section?


Wordpress does not show custom image size options in media lightbox, but you can include them utilizing an attachment_fields_to_edit filter. The below will prove to add options for the custom image dimensions you've defined.

add_filter('attachment_fields_to_edit', 'my_attachment_fields_to_edit_filter', 100, 2);

function my_attachment_fields_to_edit_filter($form_fields, $post) {
  if (!array_key_exists('image-size', $form_fields)) return $form_fields;

  global $_wp_additional_image_sizes;
  foreach($_wp_additional_image_sizes as $size => $properties) {
    if ($size == 'post-thumbnail') continue;

    $label = ucwords(str_replace('-', ' ', $size));
    $cssID = "image-size-{$size}-{$post->ID}";

    $downsize = image_downsize($post->ID, $size);
    $enabled = $downsize[3];

    $html = '<input type="radio" ' . disabled($enabled, false, false) . 'name="attachments[' . $post->ID. '][image-size]" id="' . $cssID . '" value="' . $size .'">';
    $html .= '<label for="'. $cssID . '">' . $label . '</label>';
    if ($enabled) $html .= ' <label for="' . $cssID . '" class="help">(' . $downsize[1] . '&nbsp;×&nbsp;' . $downsize[2] . ')</label>';
    $form_fields['image-size']['html'] .= '<div class="image-size-item">' . $html . '</div>';

  return $form_fields;