WordPress.org

Make WordPress Core

Changeset 12007


Ignore:
Timestamp:
10/07/2009 10:18:09 PM (9 years ago)
Author:
markjaquith
Message:

First pass on canonical post thumbanils. Admin-side GUI only. Theme functions to follow. see #10928

Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r11986 r12007  
    13711371    die();
    13721372    break;
     1373case 'set-post-thumbnail':
     1374    $post_id = intval( $_POST['post_id'] );
     1375    if ( !current_user_can( 'edit_post', $post_id ) )
     1376        die( '-1' );
     1377    $thumbnail_id = intval( $_POST['thumbnail_id'] );
     1378    if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
     1379        $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' );
     1380        if ( !empty( $thumbnail_html ) ) {
     1381            update_post_meta( $post_id, '_thumbnail_id', $thumbnail_id );
     1382            die( _wp_post_thumbnail_html( $thumbnail_id ) );
     1383        }
     1384    }
     1385    die( '0' );
    13731386default :
    13741387    do_action( 'wp_ajax_' . $_POST['action'] );
  • trunk/wp-admin/css/media.css

    r11965 r12007  
    1 div#media-upload-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;height:2.5em;}body#media-upload ul#sidemenu{font-weight:normal;margin:0 5px;position:absolute;left:0;bottom:-1px;}div#media-upload-error{margin:1em;font-weight:bold;}form{margin:1em;}#search-filter{text-align:right;}th{position:relative;}.media-upload-form label.form-help,td.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}.media-upload-form p.help{margin:0;padding:0;}.media-upload-form fieldset{width:100%;border:none;text-align:justify;margin:0 0 1em 0;padding:0;}.image-align-none-label{background:url(../images/align-none.png) no-repeat center left;}.image-align-left-label{background:url(../images/align-left.png) no-repeat center left;}.image-align-center-label{background:url(../images/align-center.png) no-repeat center left;}.image-align-right-label{background:url(../images/align-right.png) no-repeat center left;}tr.image-size td{width:460px;}tr.image-size div.image-size-item{float:left;width:25%;margin:0;}#library-form .progress,#gallery-form .progress,#flash-upload-ui,.insert-gallery,.describe.startopen,.describe.startclosed{display:none;}.media-item .thumbnail{max-width:128px;max-height:128px;}thead.media-item-info tr{background-color:transparent;}thead.media-item-info th,thead.media-item-info td{border:none;margin:0;}.form-table thead.media-item-info{border:8px solid #fff;}abbr.required{text-decoration:none;border:none;}.describe label{display:inline;}.describe td{vertical-align:middle;padding:0 5px 8px 0;}.describe td.A1{width:132px;}.describe input[type="text"],.describe textarea{width:460px;border-width:1px;border-style:solid;}.describe-toggle-on,.describe-toggle-off{display:block;line-height:36px;float:right;margin-right:20px;}.describe-toggle-off{display:none;}.hidden{height:0;width:0;overflow:hidden;border:none;}#media-upload p.ml-submit{padding:1em 0;}#media-upload p.help,#media-upload label.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}#media-upload tr.image-size td.field{text-align:center;}#media-upload #media-items{border-width:1px;border-style:solid;border-bottom:none;width:623px;}#media-upload .media-item{border-bottom-width:1px;border-bottom-style:solid;min-height:36px;width:100%;}#media-upload .ui-sortable .media-item{cursor:move;}.filename{line-height:36px;padding:0 10px;overflow:hidden;}#media-upload .describe{padding:5px;width:100%;clear:both;cursor:default;}#media-upload .slidetoggle{border-top-width:1px;border-top-style:solid;}#media-upload .describe th.label{padding-top:.2em;text-align:left;min-width:120px;}#media-upload tr.align td.field{text-align:center;}#media-upload tr.image-size{margin-bottom:1em;height:3em;}#media-upload #filter{width:623px;}#media-upload #filter .subsubsub{margin:8px 0;}#filter .tablenav select{border-style:solid;border-width:1px;padding:2px;vertical-align:top;width:auto;}#media-upload .del-attachment{display:none;margin:5px 0;}.menu_order{float:right;font-size:11px;margin:10px 10px 0;}.menu_order_input{border:1px solid #ddd;font-size:10px;padding:1px;width:23px;}.ui-sortable-helper{background-color:#fff;border:1px solid #aaa;opacity:.6;filter:alpha(opacity=60);}#media-upload th.order-head{width:25%;text-align:center;}#media-upload .widefat{width:626px;border-style:solid solid none;}.sorthelper{height:37px;width:623px;display:block;}#gallery-settings th.label{width:160px;}#gallery-settings #basic th.label{padding:5px 5px 5px 0;}#gallery-settings .title{clear:both;padding:0 0 3px;border-bottom-style:solid;border-bottom-width:1px;font-family:Georgia,"Times New Roman",Times,serif;font-size:1.6em;border-bottom-color:#DADADA;color:#5A5A5A;}h3.media-title{color:#5A5A5A;font-family:Georgia,"Times New Roman",Times,serif;font-size:1.6em;font-weight:normal;}#gallery-settings .describe td{vertical-align:middle;height:3.5em;}#gallery-settings .describe th.label{padding-top:.5em;text-align:left;}#gallery-settings .describe{padding:5px;width:615px;clear:both;cursor:default;}#gallery-settings .describe select{width:15em;border:1px solid #dfdfdf;}#gallery-settings label,#gallery-settings legend{font-size:13px;color:#464646;margin-right:15px;}#gallery-settings .align .field label{margin:0 1.5em 0 0;}#gallery-settings p.ml-submit{border-top:1px solid #dfdfdf;}#gallery-settings select#columns{width:6em;}#sort-buttons{font-size:.8em;margin:3px 25px -8px 0;text-align:right;max-width:625px;}#sort-buttons a{text-decoration:none;}#sort-buttons #asc,#sort-buttons #showall{padding-left:5px;}#sort-buttons span{margin-right:25px;}
     1div#media-upload-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;height:2.5em;}body#media-upload ul#sidemenu{font-weight:normal;margin:0 5px;position:absolute;left:0;bottom:-1px;}div#media-upload-error{margin:1em;font-weight:bold;}form{margin:1em;}#search-filter{text-align:right;}th{position:relative;}.media-upload-form label.form-help,td.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}.media-upload-form p.help{margin:0;padding:0;}.media-upload-form fieldset{width:100%;border:none;text-align:justify;margin:0 0 1em 0;padding:0;}.image-align-none-label{background:url(../images/align-none.png) no-repeat center left;}.image-align-left-label{background:url(../images/align-left.png) no-repeat center left;}.image-align-center-label{background:url(../images/align-center.png) no-repeat center left;}.image-align-right-label{background:url(../images/align-right.png) no-repeat center left;}tr.image-size td{width:460px;}tr.image-size div.image-size-item{float:left;width:25%;margin:0;}#library-form .progress,#gallery-form .progress,#flash-upload-ui,.insert-gallery,.describe.startopen,.describe.startclosed{display:none;}.media-item .thumbnail{max-width:128px;max-height:128px;}thead.media-item-info tr{background-color:transparent;}thead.media-item-info th,thead.media-item-info td{border:none;margin:0;}.form-table thead.media-item-info{border:8px solid #fff;}abbr.required{text-decoration:none;border:none;}.describe label{display:inline;}.describe td{vertical-align:middle;padding:0 5px 8px 0;}.describe td.A1{width:132px;}.describe input[type="text"],.describe textarea{width:460px;border-width:1px;border-style:solid;}.describe-toggle-on,.describe-toggle-off{display:block;line-height:36px;float:right;margin-right:20px;}.describe-toggle-off{display:none;}.hidden{height:0;width:0;overflow:hidden;border:none;}#media-upload p.ml-submit{padding:1em 0;}#media-upload p.help,#media-upload label.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}#media-upload tr.image-size td.field{text-align:center;}#media-upload #media-items{border-width:1px;border-style:solid;border-bottom:none;width:623px;}#media-upload .media-item{border-bottom-width:1px;border-bottom-style:solid;min-height:36px;width:100%;}#media-upload .ui-sortable .media-item{cursor:move;}.filename{line-height:36px;padding:0 10px;overflow:hidden;}#media-upload .describe{padding:5px;width:100%;clear:both;cursor:default;}#media-upload .slidetoggle{border-top-width:1px;border-top-style:solid;}#media-upload .describe th.label{padding-top:.2em;text-align:left;min-width:120px;}#media-upload tr.align td.field{text-align:center;}#media-upload tr.image-size{margin-bottom:1em;height:3em;}#media-upload #filter{width:623px;}#media-upload #filter .subsubsub{margin:8px 0;}#filter .tablenav select{border-style:solid;border-width:1px;padding:2px;vertical-align:top;width:auto;}#media-upload .del-attachment{display:none;margin:5px 0;}.menu_order{float:right;font-size:11px;margin:10px 10px 0;}.menu_order_input{border:1px solid #ddd;font-size:10px;padding:1px;width:23px;}.ui-sortable-helper{background-color:#fff;border:1px solid #aaa;opacity:.6;filter:alpha(opacity=60);}#media-upload th.order-head{width:20%;text-align:center;}#media-upload th.actions-head{width:25%;text-align:center;}#media-upload a.wp-post-thumbnail{display:block;line-height:36px;float:right;margin-right:20px;}#media-upload .widefat{width:626px;border-style:solid solid none;}.sorthelper{height:37px;width:623px;display:block;}#gallery-settings th.label{width:160px;}#gallery-settings #basic th.label{padding:5px 5px 5px 0;}#gallery-settings .title{clear:both;padding:0 0 3px;border-bottom-style:solid;border-bottom-width:1px;font-family:Georgia,"Times New Roman",Times,serif;font-size:1.6em;border-bottom-color:#DADADA;color:#5A5A5A;}h3.media-title{color:#5A5A5A;font-family:Georgia,"Times New Roman",Times,serif;font-size:1.6em;font-weight:normal;}#gallery-settings .describe td{vertical-align:middle;height:3.5em;}#gallery-settings .describe th.label{padding-top:.5em;text-align:left;}#gallery-settings .describe{padding:5px;width:615px;clear:both;cursor:default;}#gallery-settings .describe select{width:15em;border:1px solid #dfdfdf;}#gallery-settings label,#gallery-settings legend{font-size:13px;color:#464646;margin-right:15px;}#gallery-settings .align .field label{margin:0 1.5em 0 0;}#gallery-settings p.ml-submit{border-top:1px solid #dfdfdf;}#gallery-settings select#columns{width:6em;}#sort-buttons{font-size:.8em;margin:3px 25px -8px 0;text-align:right;max-width:625px;}#sort-buttons a{text-decoration:none;}#sort-buttons #asc,#sort-buttons #showall{padding-left:5px;}#sort-buttons span{margin-right:25px;}
  • trunk/wp-admin/css/media.dev.css

    r11965 r12007  
    264264
    265265#media-upload th.order-head {
     266    width: 20%;
     267    text-align: center;
     268}
     269
     270#media-upload th.actions-head {
    266271    width: 25%;
    267272    text-align: center;
     273}
     274
     275#media-upload a.wp-post-thumbnail{
     276    display: block;
     277    line-height: 36px;
     278    float: right;
     279    margin-right: 20px;
    268280}
    269281
  • trunk/wp-admin/edit-form-advanced.php

    r11897 r12007  
    7575
    7676add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
     77add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low');
    7778// add_meta_box('passworddiv', __('Privacy Options'), 'post_password_meta_box', 'post', 'side', 'core');
    7879add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
  • trunk/wp-admin/includes/media.php

    r11989 r12007  
    113113
    114114    return $html;
     115}
     116
     117function _wp_post_thumbnail_html( $thumbnail_id = NULL ) {
     118    if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
     119        $thumbnail_html = wp_get_attachment_image($thumbnail_id, 'thumbnail');
     120        if ( !empty( $thumbnail_html ) )
     121            return '<a href="#" id="cws-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . $thumbnail_html . '</a>';
     122    }
     123    return '<a href="#" id="cws-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . esc_html__( 'Set thumbnail' ) . '</a>';
     124}
     125
     126function post_thumbnail_meta_box() {
     127    global $post;
     128    $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
     129    echo _wp_post_thumbnail_html( $thumbnail_id );
    115130}
    116131
     
    11361151        $toggle_links = "
    11371152    <a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
    1138     <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
     1153    <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>
     1154    <a class='wp-post-thumbnail' href='#' onclick='WPSetAsThumbnail(\"" . intval( $attachment_id ) . "\");return false;'>" . esc_html__( "Use for thumbnail" ) . "</a>";
    11391155    } else {
    11401156        $class = 'form-table';
     
    16301646<th><?php _e('Media'); ?></th>
    16311647<th class="order-head"><?php _e('Order'); ?></th>
     1648<th class="actions-head"><?php _e('Actions'); ?></th>
    16321649</tr></thead>
    16331650</table>
  • trunk/wp-admin/media-upload.php

    r11911 r12007  
    1919wp_enqueue_script('swfupload-handlers');
    2020wp_enqueue_script('image-edit');
     21wp_enqueue_script('set-post-thumbnail' );
    2122wp_enqueue_style('imgareaselect');
    2223
  • trunk/wp-admin/post-new.php

    r9620 r12007  
    1919wp_enqueue_script('media-upload');
    2020wp_enqueue_script('word-count');
     21wp_enqueue_script( 'set-post-thumbnail-handler' );
    2122
    2223if ( ! current_user_can('edit_posts') ) {
  • trunk/wp-admin/post.php

    r11986 r12007  
    140140    wp_enqueue_script('media-upload');
    141141    wp_enqueue_script('word-count');
     142    wp_enqueue_script( 'set-post-thumbnail-handler' );
    142143    wp_enqueue_script( 'admin-comments' );
    143144    enqueue_comment_hotkeys_js();
  • trunk/wp-includes/script-loader.php

    r11984 r12007  
    408408        $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), '20090929' );
    409409        $scripts->add_data( 'image-edit', 'group', 1 );
     410
     411        $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), '20091005' );
     412        $scripts->add_data( 'set-post-thumbnail', 'group', 1 );
     413        $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
     414            'setThumbnail' => __( 'Use for thumbnail' ),
     415            'saving' => __( 'Saving...' ),
     416            'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' )
     417        ) );
     418
     419        $scripts->add( 'set-post-thumbnail-handler', "/wp-admin/js/set-post-thumbnail-handler$suffix.js", array( 'jquery' ), '20091005' );
     420        $scripts->add_data( 'set-post-thumbnail-handler', 'group', 1 );
     421   
    410422    }
    411423}
     
    461473
    462474    $styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20090630' );
    463     $styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20090922' );
     475    $styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20091005' );
    464476    $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20090603' );
    465477    $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20090514' );
Note: See TracChangeset for help on using the changeset viewer.