Changeset 22528 for trunk/wp-admin/includes/meta-boxes.php
- Timestamp:
- 11/10/2012 08:40:35 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/meta-boxes.php
r22500 r22528 1010 1010 title = '<?php _e( "Choose a Featured Image" ); ?>', 1011 1011 update = '<?php _e( "Update Featured Image" ); ?>', 1012 Attachment = wp.media.model.Attachment, 1012 1013 frame, setFeaturedImage; 1013 1014 1014 1015 setFeaturedImage = function( thumbnailId ) { 1016 var selection; 1017 1015 1018 $element.find('img').remove(); 1016 1019 $element.toggleClass( 'has-featured-image', -1 != thumbnailId ); 1017 1020 $thumbnailId.val( thumbnailId ); 1021 1022 if ( frame ) { 1023 selection = frame.get('library').get('selection'); 1024 1025 if ( -1 === thumbnailId ) 1026 selection.clear(); 1027 else 1028 selection.add( Attachment.get( thumbnailId ) ); 1029 } 1018 1030 }; 1019 1031 1020 1032 $element.on( 'click', '.choose, img', function( event ) { 1033 var options, thumbnailId; 1034 1021 1035 event.preventDefault(); 1022 1036 … … 1026 1040 } 1027 1041 1028 frame = wp.media({ 1029 title: title, 1030 selection: [ wp.media.model.Attachment.get( $thumbnailId.val() ) ], 1031 library: { 1042 options = { 1043 title: title, 1044 library: { 1032 1045 type: 'image' 1033 1046 } 1034 }); 1047 }; 1048 1049 thumbnailId = $thumbnailId.val(); 1050 if ( '' !== thumbnailId && -1 !== thumbnailId ) 1051 options.selection = [ Attachment.get( thumbnailId ) ]; 1052 1053 frame = wp.media( options ); 1035 1054 1036 1055 frame.toolbar.on( 'activate:select', function() {
Note: See TracChangeset
for help on using the changeset viewer.