Show file url after upload form media library, props yoavf, fixes #9267

git-svn-id: http://svn.automattic.com/wordpress/trunk@10696 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-03-04 08:22:25 +00:00
parent 53c53c0bc8
commit 65e0cea07b
4 changed files with 30 additions and 1 deletions

View File

@ -30,6 +30,7 @@ if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id
add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
echo get_media_item($id, array( 'send' => false, 'delete' => false ));
} else {
add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
echo get_media_item($id);
}
exit;
@ -53,4 +54,4 @@ else {
echo apply_filters("async_upload_{$type}", $id);
}
?>
?>

View File

@ -1577,3 +1577,7 @@ fieldset.inline-edit-col-right .inline-edit-col {
#header-logo {
background: transparent url(../images/wp-logo.gif) no-repeat scroll center center;
}
input[readonly] {
background-color: #eee;
}

View File

@ -1577,3 +1577,7 @@ fieldset.inline-edit-col-right .inline-edit-col {
#header-logo {
background: transparent url(../images/wp-logo.gif) no-repeat scroll center center;
}
input[readonly] {
background-color: #eee;
}

View File

@ -838,6 +838,9 @@ function image_link_input_fields($post, $url_type='') {
function image_attachment_fields_to_edit($form_fields, $post) {
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
$form_fields['post_title']['required'] = true;
$file = wp_get_attachment_url($post->ID);
$form_fields['image_url']['value'] = $file;
$form_fields['post_excerpt']['label'] = __('Caption');
$form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image');
@ -871,6 +874,11 @@ function media_single_attachment_fields_to_edit( $form_fields, $post ) {
return $form_fields;
}
function media_post_single_attachment_fields_to_edit( $form_fields, $post ) {
unset($form_fields['image_url']);
return $form_fields;
}
/**
* {@internal Missing Short Description}}
*
@ -943,6 +951,8 @@ function get_attachment_fields_to_edit($post, $errors = null) {
if ( is_array($post) )
$post = (object) $post;
$image_url = wp_get_attachment_url($post->ID);
$edit_post = sanitize_post($post, 'edit');
$form_fields = array(
@ -969,6 +979,13 @@ function get_attachment_fields_to_edit($post, $errors = null) {
'label' => __('Order'),
'value' => $edit_post->menu_order
),
'image_url' => array(
'label' => __('File URL'),
'input' => 'html',
'html' => "<input type='text' class='urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . attribute_escape($image_url) . "' /><br />",
'value' => $edit_post->post_url,
'helps' => __('Location of the uploaded file.'),
)
);
foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
@ -1371,6 +1388,7 @@ jQuery(function($){
<?php
if ( $id ) {
if ( !is_wp_error($id) ) {
add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
echo get_media_items( $id, $errors );
} else {
echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
@ -1537,6 +1555,7 @@ jQuery(function($){
</tr></thead>
</table>
<div id="media-items">
<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
<?php echo get_media_items($post_id, $errors); ?>
</div>
@ -1770,6 +1789,7 @@ jQuery(function($){
</script>
<div id="media-items">
<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
<?php echo get_media_items(null, $errors); ?>
</div>
<p class="ml-submit">