Show file url after upload form media library, props yoavf, fixes #9267
git-svn-id: https://develop.svn.wordpress.org/trunk@10696 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
891e588a54
commit
37664340f5
@ -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);
|
add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
|
||||||
echo get_media_item($id, array( 'send' => false, 'delete' => false ));
|
echo get_media_item($id, array( 'send' => false, 'delete' => false ));
|
||||||
} else {
|
} else {
|
||||||
|
add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
|
||||||
echo get_media_item($id);
|
echo get_media_item($id);
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
@ -53,4 +54,4 @@ else {
|
|||||||
echo apply_filters("async_upload_{$type}", $id);
|
echo apply_filters("async_upload_{$type}", $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -1577,3 +1577,7 @@ fieldset.inline-edit-col-right .inline-edit-col {
|
|||||||
#header-logo {
|
#header-logo {
|
||||||
background: transparent url(../images/wp-logo.gif) no-repeat scroll center center;
|
background: transparent url(../images/wp-logo.gif) no-repeat scroll center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input[readonly] {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
@ -1577,3 +1577,7 @@ fieldset.inline-edit-col-right .inline-edit-col {
|
|||||||
#header-logo {
|
#header-logo {
|
||||||
background: transparent url(../images/wp-logo.gif) no-repeat scroll center center;
|
background: transparent url(../images/wp-logo.gif) no-repeat scroll center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input[readonly] {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
@ -838,6 +838,9 @@ function image_link_input_fields($post, $url_type='') {
|
|||||||
function image_attachment_fields_to_edit($form_fields, $post) {
|
function image_attachment_fields_to_edit($form_fields, $post) {
|
||||||
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
|
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
|
||||||
$form_fields['post_title']['required'] = true;
|
$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']['label'] = __('Caption');
|
||||||
$form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image');
|
$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;
|
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}}
|
* {@internal Missing Short Description}}
|
||||||
*
|
*
|
||||||
@ -943,6 +951,8 @@ function get_attachment_fields_to_edit($post, $errors = null) {
|
|||||||
if ( is_array($post) )
|
if ( is_array($post) )
|
||||||
$post = (object) $post;
|
$post = (object) $post;
|
||||||
|
|
||||||
|
$image_url = wp_get_attachment_url($post->ID);
|
||||||
|
|
||||||
$edit_post = sanitize_post($post, 'edit');
|
$edit_post = sanitize_post($post, 'edit');
|
||||||
|
|
||||||
$form_fields = array(
|
$form_fields = array(
|
||||||
@ -969,6 +979,13 @@ function get_attachment_fields_to_edit($post, $errors = null) {
|
|||||||
'label' => __('Order'),
|
'label' => __('Order'),
|
||||||
'value' => $edit_post->menu_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 ) {
|
foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
|
||||||
@ -1371,6 +1388,7 @@ jQuery(function($){
|
|||||||
<?php
|
<?php
|
||||||
if ( $id ) {
|
if ( $id ) {
|
||||||
if ( !is_wp_error($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 );
|
echo get_media_items( $id, $errors );
|
||||||
} else {
|
} else {
|
||||||
echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
|
echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
|
||||||
@ -1537,6 +1555,7 @@ jQuery(function($){
|
|||||||
</tr></thead>
|
</tr></thead>
|
||||||
</table>
|
</table>
|
||||||
<div id="media-items">
|
<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); ?>
|
<?php echo get_media_items($post_id, $errors); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -1770,6 +1789,7 @@ jQuery(function($){
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="media-items">
|
<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); ?>
|
<?php echo get_media_items(null, $errors); ?>
|
||||||
</div>
|
</div>
|
||||||
<p class="ml-submit">
|
<p class="ml-submit">
|
||||||
|
Loading…
Reference in New Issue
Block a user