php - How can I add custom image sizes to wordpress but have them in the admin? -
i know how use add_image_size in php register new size can used in templates. makes images in size, when they're uploaded.
the sizes added don't show in admin, though.
so 2 questions...
how can image sizes make show in 'upload image' thing when bloggers make new post?
is there way list in admin bloggers can add new ones without having change php code?
or doing wrong, not putting add_image_size call in right place/file? sizes supposed show in upload menu section?
cole
wordpress doesn't show custom image size options in media lightbox, can add them using attachment_fields_to_edit filter. below add options custom image sizes have 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 $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] . ' × ' . $downsize[2] . ')</label>'; $form_fields['image-size']['html'] .= '<div class="image-size-item">' . $html . '</div>'; } return $form_fields; }
Comments
Post a Comment