Make WordPress Core


Ignore:
Timestamp:
11/21/2012 01:05:44 PM (12 years ago)
Author:
nacin
Message:

Have media-new.php return simple rows of basic attachment data, with an 'Edit' link next to each taking them to post.php (in a new window). Not ideal, but this is largely a fallback screen at this point.

This is bolted on to existing code, the vast majority of which is destined to be ripped out in 3.6 once things settle.

see #22083.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/async-upload.php

    r19712 r22755  
    3838        wp_die( __( 'You are not allowed to edit this item.' ) );
    3939
    40     if ( 2 == $_REQUEST['fetch'] ) {
    41         add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
    42         echo get_media_item($id, array( 'send' => false, 'delete' => true ));
    43     } else {
    44         add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
    45         echo get_media_item($id);
     40    switch ( $_REQUEST['fetch'] ) {
     41        case 3 :
     42            if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) )
     43                echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
     44            echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>';
     45            $title = $post->post_title ? $post->post_title : wp_basename( $post->guid ); // title shouldn't ever be empty, but use filename just in cas.e
     46            echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60 ) ) . '</span></div>';
     47            break;
     48        case 2 :
     49            add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
     50            echo get_media_item($id, array( 'send' => false, 'delete' => true ));
     51            break;
     52        default:
     53            add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
     54            echo get_media_item($id);
     55            break;
    4656    }
    4757    exit;
Note: See TracChangeset for help on using the changeset viewer.