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.



git-svn-id: http://core.svn.wordpress.org/trunk@22755 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-11-21 13:05:44 +00:00
parent 68e4e2c4a6
commit e276fc44be
6 changed files with 37 additions and 12 deletions

View File

@ -37,12 +37,22 @@ if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id
if ( ! current_user_can( $post_type_object->cap->edit_post, $id ) )
wp_die( __( 'You are not allowed to edit this item.' ) );
if ( 2 == $_REQUEST['fetch'] ) {
add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
echo get_media_item($id, array( 'send' => false, 'delete' => true ));
} else {
add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
echo get_media_item($id);
switch ( $_REQUEST['fetch'] ) {
case 3 :
if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) )
echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>';
$title = $post->post_title ? $post->post_title : wp_basename( $post->guid ); // title shouldn't ever be empty, but use filename just in cas.e
echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60 ) ) . '</span></div>';
break;
case 2 :
add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
echo get_media_item($id, array( 'send' => false, 'delete' => true ));
break;
default:
add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
echo get_media_item($id);
break;
}
exit;
}

View File

@ -1049,6 +1049,7 @@ span.description,
padding: 0 5px 0 0;
}
.media-item .edit-attachment,
.media-item .error-div a.dismiss,
.describe-toggle-on,
.describe-toggle-off {

View File

@ -3817,6 +3817,7 @@ abbr.required {
padding: 0 0 0 5px;
}
.media-item .edit-attachment,
.describe-toggle-on,
.describe-toggle-off {
display: block;
@ -3848,6 +3849,10 @@ abbr.required {
width: 623px;
}
.media-new-php #media-items {
margin: 1em 0;
}
#media-items:empty {
border: 0 none;
}
@ -5533,10 +5538,10 @@ body.full-overlay-active {
margin: 0;
}
.wp-full-overlay-sidebar .wp-full-overlay-header {
border-top: 0;
border-bottom: 1px solid #fff;
box-shadow: inset 0 -1px 0 0px #dfdfdf;
.wp-full-overlay-sidebar .wp-full-overlay-header {
border-top: 0;
border-bottom: 1px solid #fff;
box-shadow: inset 0 -1px 0 0px #dfdfdf;
}
.wp-full-overlay-sidebar .wp-full-overlay-footer {

View File

@ -1055,11 +1055,18 @@ function get_media_items( $post_id, $errors ) {
function get_media_item( $attachment_id, $args = null ) {
global $redir_tab;
echo "<a class='toggle describe-toggle-on' href='#'>$toggle_on</a>";
if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) )
$thumb_url = $thumb_url[0];
else
$thumb_url = false;
$display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
$display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : '';
echo "<p><a href='$attachment_url' target='_blank'><img class='thumbnail' src='$thumb_url' alt='' /></a></p>";
$post = get_post( $attachment_id );
$current_post_id = !empty( $_GET['post_id'] ) ? (int) $_GET['post_id'] : 0;

View File

@ -90,7 +90,7 @@ if ( $_POST ) {
}
updateMediaForm();
post_id = 0;
shortform = 1;
shortform = 3;
});
</script>
<input type="hidden" name="post_id" id="post_id" value="0" />

View File

@ -112,6 +112,8 @@ function setResize(arg) {
function prepareMediaItem(fileObj, serverData) {
var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
if ( f == 2 && shortform > 2 )
f = shortform;
try {
if ( typeof topWin.tb_remove != 'undefined' )
@ -429,7 +431,7 @@ jQuery(document).ready(function($){
$('#drag-drop-area').unbind('.wp-uploader');
}
if ( up.runtime == 'html4' )
if ( up.runtime == 'html4' )
$('.upload-flash-bypass').hide();
});