wordpress - Size of featured image in admin panel? -
been experimenting custom meta boxes, nothing i've read or can find helping me achieve i'm after.
i can render new meta box, can't find way change output of post thumbnail in admin panel.
function new_post_thumbnail_meta_box() { global $post; echo 'content above image.'; $thumbnail_id = get_post_meta( $post->id, '_thumbnail_id', true ); echo _wp_post_thumbnail_html( $thumbnail_id ); echo 'content below image.'; } function render_new_post_thumbnail_meta_box() { global $post_type; // remove old meta box remove_meta_box( 'postimagediv','post','side' ); // adding new meta box. add_meta_box('postimagediv', __('featured image'), 'new_post_thumbnail_meta_box', $post_type, 'side', 'low'); } add_action('do_meta_boxes', 'render_new_post_thumbnail_meta_box');
how have larger or 'actual size' version of featured image displayed in administration panel?
copied includes function , modified output, throws server error.
function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { global $content_width, $_wp_additional_image_sizes; $post = get_post( $post ); $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post->id ) ); $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'set featured image' ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>'; $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'set featured image' ) ); if ( $thumbnail_id && get_post( $thumbnail_id ) ) { $old_content_width = $content_width; $content_width = 600; if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) ) $thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) ); else $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' ); if ( !empty( $thumbnail_html ) ) { $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->id ); $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html ); $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="wpremovethumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'remove featured image' ) . '</a></p>'; } $content_width = $old_content_width; } return apply_filters( 'admin_post_thumbnail_html', $content, $post->id ); }
or should using add_image_size( 'post_thumbnail', 600, 400, true ); ? since that's looks for?
just in case stumbling on old post.
wp introduced new filter called admin_post_thumbnail_size able change default image size in admin panel.
to change size of featured thumbnail image can use this:
function custom_admin_thumb_size($thumb_size){ return "custom-image-size"; //or use array(400,400). } add_filter( 'admin_post_thumbnail_size', 'custom_admin_thumb_size');
Comments
Post a Comment