Ticket #33011: 33011.2.diff
File 33011.2.diff, 2.4 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
3080 3080 require_once ABSPATH . '/wp-admin/includes/class-wp-site-icon.php'; 3081 3081 global $wp_site_icon; 3082 3082 3083 // Skip creating a new attachment if the attachment is a Site Icon. 3084 if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) { 3085 add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) ); 3086 break; 3087 } 3088 3083 3089 /** This filter is documented in wp-admin/custom-header.php */ 3084 3090 $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. 3085 3091 $object = $wp_site_icon->create_attachment_object( $cropped, $attachment_id ); -
src/wp-admin/js/customize-controls.js
2076 2076 }, 2077 2077 2078 2078 /** 2079 * After an image is selected in the media modal, switch to the cropper 2080 * state if the image isn't the right size. 2081 */ 2082 onSelect: function() { 2083 var attachment = this.frame.state().get( 'selection' ).first().toJSON(), 2084 controller = this; 2085 2086 if ( this.params.width === attachment.width && this.params.height === attachment.height && ! this.params.flex_width && ! this.params.flex_height ) { 2087 console.log(attachment); 2088 wp.ajax.post( 'crop-image', { 2089 nonce: attachment.nonces.edit, 2090 id: attachment.id, 2091 context: 'site-icon', 2092 cropDetails: { 2093 x1: 0, 2094 y1: 0, 2095 width: this.params.width, 2096 height: this.params.height, 2097 dst_width: this.params.width, 2098 dst_height: this.params.height 2099 } 2100 } ).done( function( croppedImage ) { 2101 controller.setImageFromAttachment( croppedImage ); 2102 controller.frame.close(); 2103 } ).fail( function() { 2104 controller.trigger('content:error:crop'); 2105 } ); 2106 } else { 2107 this.frame.setState( 'cropper' ); 2108 } 2109 }, 2110 2111 /** 2079 2112 * Updates the setting and re-renders the control UI. 2080 2113 * 2081 2114 * @param {object} attachment … … 2090 2123 2091 2124 2092 2125 // Update the icon in-browser. 2093 $( 'link[ rel="icon"]' ).attr( 'href', icon.url );2126 $( 'link[sizes="32x32"]' ).attr( 'href', icon.url ); 2094 2127 }, 2095 2128 2096 2129 /**