Uživatelský rozměr obrázku a jeho přidání do administrace

WordPress doesn’t show custom image size options in the media lightbox, but you can add them using an attachment_fields_to_edit filter. The below will add options for all the custom image sizes you have defined.

/—code php

add_theme_support( ‚post-thumbnails‘ );
add_image_size( ‚custom_size_image‘, 80, 80 );

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 = ‚‚ . $label . ‚‚;
if ($enabled) $html .= ‚ ‚;
$form_fields[‚image-size‘][‚html‘] .= ‚

‚ . $html . ‚

‚;
}

return $form_fields;
}
\—

„Zdroj »“:http://stackoverflow.com/questions/5032906/how-can-i-add-custom-image-sizes-to-wordpress-but-have-them-in-the-admin