Ticket #19570: 19570.28.patch
File 19570.28.patch, 5.6 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/post.php
200 200 update_post_meta( $post_ID, '_wp_format_url', wp_slash( esc_url_raw( wp_unslash( $post_data['_wp_format_url'] ) ) ) ); 201 201 } 202 202 203 $format_keys = array( 'quote', 'quote_source', 'image', ' gallery', 'audio', 'video' );203 $format_keys = array( 'quote', 'quote_source', 'image', 'image_id', 'gallery', 'audio', 'video' ); 204 204 205 205 foreach ( $format_keys as $key ) { 206 206 if ( isset( $post_data[ '_wp_format_' . $key ] ) ) -
wp-admin/includes/post-formats.php
19 19 </div> 20 20 21 21 <?php 22 $image = false; 23 if ( ! empty( $format_meta['image'] ) && is_numeric( $format_meta['image'] ) ) { 24 $format_meta['image'] = absint( $format_meta['image'] ); 25 $image = wp_get_attachment_url( $format_meta['image'] ); 26 } 22 $show_image_preview = ! empty( $format_meta['image'] ) || ! empty( $format_meta['image_id'] ); 27 23 ?> 28 24 <div class="field wp-format-image"> 25 <?php if ( $show_image_preview ): ?> 26 <div id="image-preview" class="wp-format-media-preview"> 27 <?php 28 if ( ! empty( $format_meta['image_id'] ) && is_numeric( $format_meta['image_id'] ) ) { 29 $image = wp_get_attachment_url( absint( $format_meta['image_id'] ) ); 30 echo '<img src="' . esc_url( $image ) . '" />'; 31 } elseif ( ! empty( $format_meta['image'] ) && ! preg_match( '#<[^>]+>#', $format_meta['image'] ) ) { 32 echo $wp_embed->autoembed( $format_meta['image'] ); 33 } elseif ( ! empty( $format_meta['image'] ) ) { 34 echo $format_meta['image']; 35 } 36 ?> 37 </div> 38 <?php endif ?> 39 <label for="_wp_format_image"><?php _e( 'Image embed code or URL' ); ?></label> 40 <textarea id="wp_format_image" type="text" name="_wp_format_image" class="widefat"><?php esc_html_e( $format_meta['image'] ); ?></textarea> 29 41 <div data-format="image" class="wp-format-media-holder hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>"> 30 42 <a href="#" class="wp-format-media-select" 31 43 data-choose="<?php esc_attr_e( 'Choose an Image' ); ?>" 32 44 data-update="<?php esc_attr_e( 'Select Image' ); ?>"> 33 <?php 34 if ( $image ) 35 echo '<img src="' . esc_url( $image ) . '" />'; 36 else 37 _e( 'Select / Upload Image' ); 38 ?> 45 <?php _e( 'Select / Upload Image' ); ?> 39 46 </a> 40 47 </div> 41 <label for="_wp_format_image " class="screen-reader-text"><?php _e( 'Attachment ID' ); ?></label>42 <input id="wp_format_image " type="hidden" name="_wp_format_image" value="<?php echo esc_attr( $format_meta['image'] ); ?>" placeholder="<?php esc_attr_e( 'Attachment ID' ); ?>" class="widefat" />48 <label for="_wp_format_image_id" class="screen-reader-text"><?php _e( 'Attachment ID' ); ?></label> 49 <input id="wp_format_image_id" type="hidden" name="_wp_format_image_id" value="<?php echo esc_attr( $format_meta['image_id'] ); ?>" placeholder="<?php esc_attr_e( 'Attachment ID' ); ?>" class="widefat" /> 43 50 </div> 44 51 45 52 <div class="field wp-format-link wp-format-quote wp-format-image"> … … 113 120 </a> 114 121 </div> 115 122 </div> 116 </div> 117 No newline at end of file 123 </div> -
wp-admin/js/post-formats.js
112 112 113 113 mediaPreview = function (format, url, mime) { 114 114 $('#' + format + '-preview').remove(); 115 $holder.parent().prepend( '<div id="' + format + '-preview" class="wp-format-media-preview">' + 115 116 if ( -1 < $.inArray( format, [ 'audio', 'video'] ) ) { 117 $holder.parent().prepend( '<div id="' + format + '-preview" class="wp-format-media-preview">' + 116 118 '<' + format + ' class="wp-' + format + '-shortcode" controls="controls" preload="none">' + 117 119 '<source type="' + mime + '" src="' + url + '" />' + 118 120 '</' + format + '></div>' ); 119 $('.wp-' + format + '-shortcode').mediaelementplayer(); 121 $('.wp-' + format + '-shortcode').mediaelementplayer(); 122 } else { 123 $holder.parent().prepend( '<div id="' + format + '-preview" class="wp-format-media-preview">' + 124 '<img src="' + url + '" />' + 125 '</div>' ); 126 } 120 127 }; 121 128 122 // When an i mageis selected, run a callback.129 // When an item is selected, run a callback. 123 130 mediaFrame.on( 'select', function () { 124 131 // Grab the selected attachment. 125 132 var attachment = mediaFrame.state().get('selection').first(), mime, url, id; … … 138 145 mediaPreview('video', url, mime); 139 146 } else { 140 147 // set the hidden input's value 141 $field.val(id); 142 // Show the image in the placeholder 143 $el.html('<img src="' + url + '" />'); 144 $holder.removeClass('empty').show(); 148 $field.val(url); 149 // We are saving the ID to make it easier 150 $( '#wp_format_image_id' ).val(id); 151 // show one preview at a time 152 mediaPreview('image', url, mime); 145 153 } 146 154 }); 147 155 -
wp-admin/css/wp-admin.css
3179 3179 font-size: 1.2em; 3180 3180 } 3181 3181 3182 .wp-format-image label, 3182 3183 .wp-format-video label, 3183 3184 .wp-format-audio label { 3184 3185 float: left; … … 3237 3238 margin: 5px 0; 3238 3239 } 3239 3240 3240 #wp_format_audio, #wp_format_video { 3241 #wp_format_image, 3242 #wp_format_audio, 3243 #wp_format_video { 3241 3244 float: left; 3242 3245 margin-right: 23px; 3243 3246 max-width: 50%;