Make WordPress Core

Ticket #9267: show_url_in_media_library.patch

File show_url_in_media_library.patch, 2.8 KB (added by yoavf, 17 years ago)
  • wp-admin/async-upload.php

     
    3030                add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
    3131                echo get_media_item($id, array( 'send' => false, 'delete' => false ));
    3232        } else {
     33                add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
    3334                echo get_media_item($id);
    3435        }
    3536        exit;
  • wp-admin/includes/media.php

     
    838838function image_attachment_fields_to_edit($form_fields, $post) {
    839839        if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
    840840                $form_fields['post_title']['required'] = true;
     841                $file = wp_get_attachment_url($post->ID);
    841842
     843                $form_fields['image_url']['value'] = $file;
     844
    842845                $form_fields['post_excerpt']['label'] = __('Caption');
    843846                $form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image');
    844847
     
    871874        return $form_fields;
    872875}
    873876
     877function media_post_single_attachment_fields_to_edit( $form_fields, $post ) {
     878        unset($form_fields['image_url']);
     879        return $form_fields;
     880}
     881
     882
    874883/**
    875884 * {@internal Missing Short Description}}
    876885 *
     
    943952        if ( is_array($post) )
    944953                $post = (object) $post;
    945954
     955        $image_url = wp_get_attachment_url($post->ID);
     956               
     957               
    946958        $edit_post = sanitize_post($post, 'edit');
    947959
    948960        $form_fields = array(
     961                'image_url'          => array(
     962                        'label'      => __('File URL'),
     963                        'input'      => 'html',
     964                        'html'       => "<input type='text' class='urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . attribute_escape($image_url) . "' /><br />",
     965                        'value'      => $edit_post->post_url,
     966                ),
    949967                'post_title'   => array(
    950968                        'label'      => __('Title'),
    951969                        'value'      => $edit_post->post_title,
     
    13711389<?php
    13721390if ( $id ) {
    13731391        if ( !is_wp_error($id) ) {
     1392                add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
    13741393                echo get_media_items( $id, $errors );
    13751394        } else {
    13761395                echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
     
    15371556</tr></thead>
    15381557</table>
    15391558<div id="media-items">
     1559<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
    15401560<?php echo get_media_items($post_id, $errors); ?>
    15411561</div>
    15421562
     
    17701790</script>
    17711791
    17721792<div id="media-items">
     1793<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
    17731794<?php echo get_media_items(null, $errors); ?>
    17741795</div>
    17751796<p class="ml-submit">