Make WordPress Core

Ticket #6988: 6988.001.diff

File 6988.001.diff, 2.0 KB (added by AaronCampbell, 17 years ago)
  • trunk/wp-admin/includes/media.php

     
    213213                        $post['post_title'] = $attachment['post_title'];
    214214                if ( isset($attachment['post_excerpt']) )
    215215                        $post['post_excerpt'] = $attachment['post_excerpt'];
     216                if ( isset($attachment['menu_order']) )
     217                        $post['menu_order'] = $attachment['menu_order'];
    216218
    217219                $post = apply_filters('attachment_fields_to_save', $post, $attachment);
    218220
     
    413415                        $errors = $return;
    414416        }
    415417
     418        wp_enqueue_script('admin-gallery');
    416419        return wp_iframe( 'media_upload_gallery_form', $errors );
    417420}
    418421
     
    549552                                </script>\n",
    550553                        'helps'      => __('Enter a link URL or click above for presets.'),
    551554                ),
     555        'menu_order'   => array(
     556                        'label'      => __('Order'),
     557                        'value'      => $edit_post->menu_order
     558                ),
    552559        );
    553560
    554561        foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
  • trunk/wp-admin/js/gallery.js

     
     1jQuery(function($) {
     2        var gallerySortable;
     3        var gallerySortableInit = function() {
     4                try { // a hack to make sortables work in jQuery 1.2+ and IE7
     5                        $('#media-items').SortableDestroy();
     6                } catch(e) {}
     7                $('#media-items .media-item').
     8                gallerySortable = $('#media-items').Sortable( {
     9                        accept: 'media-item',
     10                        helperclass: 'sorthelper',
     11//                      handle: 'img.pinkynail',
     12                        onchange: galleryReorder,
     13                        onStop: gallerySortableInit
     14                } );
     15        }
     16       
     17        var galleryReorder = function(myOrder) {
     18                jQuery.each(myOrder[0]['o']['media-items'], function(i, id) {
     19                        jQuery('#' + id + ' .menu_order input')[0].value = i;
     20                })
     21        }
     22
     23        // initialize sortable
     24        gallerySortableInit();
     25        $('#media-items .media-item').css({
     26                position: 'static',
     27                cursor: 'move'
     28        });
     29});