Changeset 22321 for trunk/wp-admin/includes/meta-boxes.php
- Timestamp:
- 10/29/2012 06:56:23 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/meta-boxes.php
r22320 r22321 1019 1019 $thumbnailId = $element.find('input[name="thumbnail_id"]'), 1020 1020 title = '<?php _e( "Choose a Featured Image" ); ?>', 1021 workflow, selection, setFeaturedImage; 1021 update = '<?php _e( "Update Featured Image" ); ?>', 1022 frame, selection, setFeaturedImage; 1022 1023 1023 1024 setFeaturedImage = function( thumbnailId ) { … … 1030 1031 event.preventDefault(); 1031 1032 1032 if ( ! workflow) {1033 workflow= wp.media({1033 if ( ! frame ) { 1034 frame = wp.media({ 1034 1035 title: title, 1035 1036 library: { … … 1038 1039 }); 1039 1040 1040 selection = workflow.state().get('selection'); 1041 1042 selection.on( 'add', function( model ) { 1043 var sizes = model.get('sizes'), 1044 size; 1045 1046 setFeaturedImage( model.id ); 1047 1048 // @todo: might need a size hierarchy equivalent. 1049 if ( sizes ) 1050 size = sizes['post-thumbnail'] || sizes.medium; 1051 1052 // @todo: Need a better way of accessing full size 1053 // data besides just calling toJSON(). 1054 size = size || model.toJSON(); 1055 1056 workflow.close(); 1057 selection.clear(); 1058 1059 $( '<img />', { 1060 src: size.url, 1061 width: size.width 1062 }).prependTo( $element ); 1063 }); 1041 frame.toolbar( new wp.media.view.Toolbar({ 1042 controller: frame, 1043 items: { 1044 update: { 1045 style: 'primary', 1046 text: update, 1047 priority: 40, 1048 1049 click: function() { 1050 var selection = frame.state().get('selection'), 1051 model = selection.first(), 1052 sizes = model.get('sizes'), 1053 size; 1054 1055 setFeaturedImage( model.id ); 1056 1057 // @todo: might need a size hierarchy equivalent. 1058 if ( sizes ) 1059 size = sizes['post-thumbnail'] || sizes.medium; 1060 1061 // @todo: Need a better way of accessing full size 1062 // data besides just calling toJSON(). 1063 size = size || model.toJSON(); 1064 1065 frame.close(); 1066 selection.clear(); 1067 1068 $( '<img />', { 1069 src: size.url, 1070 width: size.width 1071 }).prependTo( $element ); 1072 } 1073 } 1074 } 1075 }) ); 1064 1076 } 1065 1077 1066 workflow.open();1078 frame.open(); 1067 1079 }); 1068 1080
Note: See TracChangeset
for help on using the changeset viewer.