Changeset 24006
- Timestamp:
- 04/17/2013 04:08:46 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/wp-admin-rtl.css
r23871 r24006 972 972 ------------------------------------------------------------------------------*/ 973 973 974 .post-format-options a { 975 border-left: 1px solid #ebebeb; 976 border-right: none; 977 } 978 979 .post-format-options a:first-child { 980 -webkit-border-bottom-left-radius: 0; 981 -webkit-border-top-left-radius: 0; 982 border-bottom-left-radius: 0; 983 border-top-left-radius: 0; 984 } 985 986 .post-format-options a:last-child { 987 -webkit-border-bottom-right-radius: 3px; 988 -webkit-border-top-right-radius: 3px; 989 border-bottom-right-radius: 3px; 990 border-top-right-radius: 3px; 991 } 992 993 .post-format-tip { 994 float: left; 995 } 974 996 975 997 976 /*------------------------------------------------------------------------------ -
trunk/wp-admin/css/wp-admin.css
r23994 r24006 3025 3025 #titlediv { 3026 3026 position: relative; 3027 margin-bottom: 10px;3027 margin-bottom: 5px; 3028 3028 } 3029 3029 … … 3048 3048 width: 100%; 3049 3049 outline: none; 3050 margin: 1px 0; 3050 3051 } 3051 3052 … … 3088 3089 3089 3090 #edit-slug-box { 3090 line-height: 2 3px;3091 min-height: 2 3px;3091 line-height: 24px; 3092 min-height: 25px; /* Yes, line-height + 1 */ 3092 3093 margin-top: 5px; 3093 padding : 0 10px;3094 padding-right: 6px; 3094 3095 } 3095 3096 … … 3931 3932 .post-formats-fields { 3932 3933 display: none; 3934 margin-bottom: 15px; 3933 3935 } 3934 3936 … … 3961 3963 } 3962 3964 3965 .wp-format-image label, 3963 3966 .wp-format-video label, 3964 3967 .wp-format-audio label { … … 3970 3973 overflow: hidden; 3971 3974 width: 40%; 3972 height: 200px; 3975 height: auto; 3976 padding: 55px 0 20px; 3973 3977 border: 1px dashed #dfdfdf; 3974 3978 background: #f5f5f5 url(../images/media-button-2x.png) no-repeat 50% 25%; 3975 }3976 3977 .wp-format-media-holder.empty,3978 .wp-format-audio .wp-format-media-holder,3979 .wp-format-video .wp-format-media-holder {3980 height: auto;3981 padding: 55px 0 20px;3982 3979 } 3983 3980 … … 4006 4003 } 4007 4004 4008 .empty .wp-format-media-select, 4009 .wp-format-audio .wp-format-media-select, 4010 .wp-format-video .wp-format-media-select { 4005 .wp-format-media-select { 4011 4006 height: 20px; 4012 4007 } … … 4023 4018 } 4024 4019 4020 #wp_format_image, 4025 4021 #wp_format_audio, 4026 4022 #wp_format_video { … … 4031 4027 } 4032 4028 4033 #icon-edit.standard { 4029 #icon-edit.standard, 4030 .post-format-options .standard { 4034 4031 background: url(../images/post-formats32.png) no-repeat -3px -4px; 4035 4032 } 4036 4033 4037 #icon-edit.image { 4034 #icon-edit.image, 4035 .post-format-options .image { 4038 4036 background: url(../images/post-formats32.png) no-repeat -43px -4px; 4039 4037 } 4040 4038 4041 #icon-edit.gallery { 4039 #icon-edit.gallery, 4040 .post-format-options .gallery { 4042 4041 background: url(../images/post-formats32.png) no-repeat -83px -4px; 4043 4042 } 4044 4043 4045 #icon-edit.audio { 4044 #icon-edit.audio, 4045 .post-format-options .audio { 4046 4046 background: url(../images/post-formats32.png) no-repeat -123px -4px; 4047 4047 } 4048 4048 4049 #icon-edit.video { 4049 #icon-edit.video, 4050 .post-format-options .video { 4050 4051 background: url(../images/post-formats32.png) no-repeat -163px -4px; 4051 4052 } 4052 4053 4053 #icon-edit.chat { 4054 #icon-edit.chat, 4055 .post-format-options .chat { 4054 4056 background: url(../images/post-formats32.png) no-repeat -202px -4px; 4055 4057 } 4056 4058 4057 #icon-edit.status { 4059 #icon-edit.status, 4060 .post-format-options .status { 4058 4061 background: url(../images/post-formats32.png) no-repeat -242px -4px; 4059 4062 } 4060 4063 4061 #icon-edit.aside { 4064 #icon-edit.aside, 4065 .post-format-options .aside { 4062 4066 background: url(../images/post-formats32.png) no-repeat -282px -4px; 4063 4067 } 4064 4068 4065 #icon-edit.quote { 4069 #icon-edit.quote, 4070 .post-format-options .quote { 4066 4071 background: url(../images/post-formats32.png) no-repeat -322px -4px; 4067 4072 } 4068 4073 4069 #icon-edit.link { 4074 #icon-edit.link, 4075 .post-format-options .link { 4070 4076 background: url(../images/post-formats32.png) no-repeat -362px -4px; 4071 4077 } … … 4073 4079 .post-format-description { 4074 4080 color: #666; 4075 display: none; 4076 margin: 10px 0; 4081 font-size: 12px; 4077 4082 } 4078 4083 4079 4084 .post-format-options { 4080 height: 29px; 4081 background: #f9f9f9; 4082 border: 1px solid #dfdfdf; 4083 -webkit-border-radius: 3px; 4084 border-radius: 3px; 4085 margin: 0 0 9px 1px; 4085 height: 50px; 4086 margin: 13px 0 10px; 4086 4087 padding: 0; 4087 4088 } 4088 4089 4089 4090 .post-format-options a { 4090 border-right: 1px solid #ebebeb;4091 4091 display: inline-block; 4092 height: 16px; 4093 width: 16px; 4094 padding: 6px; 4092 height: 34px; 4093 margin-right: 33px; 4095 4094 position: relative; 4096 4095 text-decoration: none; 4097 } 4098 4099 .post-format-options a:first-child { 4100 -webkit-border-bottom-left-radius: 3px; 4101 -webkit-border-top-left-radius: 3px; 4102 border-bottom-left-radius: 3px; 4103 border-top-left-radius: 3px; 4104 } 4105 4106 .post-format-options a.active, 4107 .post-format-options a:focus, 4108 .post-format-options a:hover { 4109 background: #eee; 4110 -webkit-box-shadow: inset 0 0 10px #ddd; 4111 box-shadow: inset 0 0 10px #ddd; 4112 outline: none; 4113 opacity: 1; 4096 text-align: center; 4114 4097 } 4115 4098 4116 4099 .post-format-options a div { 4100 height: 34px; 4101 width: 34px; 4102 margin: 0 auto; 4103 } 4104 4105 .post-format-title { 4106 color: #777; 4107 display: block; 4108 margin-top: 4px; 4109 } 4110 4111 .post-format-change, .post-format-set .post-format-options { 4112 display: none; 4113 } 4114 4115 .post-format-set .post-format-change { 4116 display: block; 4117 } 4118 4119 #poststuff .post-format-change { 4120 margin: 11px 0 13px; 4121 padding: 0; 4122 font-size: 1.5em; 4123 line-height: 18px; 4124 clear: left; 4125 } 4126 4127 .post-format-change span.icon { 4128 float: left; 4117 4129 height: 16px; 4130 margin: 2px 5px 0 0; 4118 4131 width: 16px; 4119 opacity: 0.4; 4120 } 4121 4122 .post-format-options a.active div, 4123 .post-format-options a:focus div, 4124 .post-format-options a:hover div { 4125 opacity: 1; 4126 } 4127 4128 .post-format-options .standard { 4132 } 4133 4134 .post-format-change span.icon.standard { 4129 4135 background: url(../images/post-formats.png) no-repeat -8px -8px; 4130 4136 } 4131 4137 4132 .post-format- options.image {4138 .post-format-change span.icon.image { 4133 4139 background: url(../images/post-formats.png) no-repeat -40px -8px; 4134 4140 } 4135 4141 4136 .post-format- options.gallery {4142 .post-format-change span.icon.gallery { 4137 4143 background: url(../images/post-formats.png) no-repeat -72px -8px; 4138 4144 } 4139 4145 4140 .post-format- options.audio {4146 .post-format-change span.icon.audio { 4141 4147 background: url(../images/post-formats.png) no-repeat -104px -8px; 4142 4148 } 4143 4149 4144 .post-format- options.video {4150 .post-format-change span.icon.video { 4145 4151 background: url(../images/post-formats.png) no-repeat -136px -8px; 4146 4152 } 4147 4153 4148 .post-format- options.chat {4154 .post-format-change span.icon.chat { 4149 4155 background: url(../images/post-formats.png) no-repeat -168px -8px; 4150 4156 } 4151 4157 4152 .post-format- options.status {4158 .post-format-change span.icon.status { 4153 4159 background: url(../images/post-formats.png) no-repeat -200px -8px; 4154 4160 } 4155 4161 4156 .post-format- options.aside {4162 .post-format-change span.icon.aside { 4157 4163 background: url(../images/post-formats.png) no-repeat -232px -8px; 4158 4164 } 4159 4165 4160 .post-format- options.quote {4166 .post-format-change span.icon.quote { 4161 4167 background: url(../images/post-formats.png) no-repeat -264px -8px; 4162 4168 } 4163 4169 4164 .post-format- options.link {4170 .post-format-change span.icon.link { 4165 4171 background: url(../images/post-formats.png) no-repeat -296px -8px; 4166 4172 } 4167 4173 4168 .post-format-tip { 4169 color: #999; 4170 font-size: 14px; 4171 float: right; 4172 padding: 6px 10px; 4173 text-transform: capitalize; 4174 .post-format-change a { 4175 font-size: 12px; 4176 } 4177 4178 @media only screen and (max-width: 782px) { 4179 .post-format-options { 4180 height: 33px; 4181 } 4182 4183 .post-format-options a { 4184 margin-right: 19px; 4185 } 4186 4187 .post-format-options a div { 4188 height: 18px; 4189 width: 16px; 4190 } 4191 4192 .post-format-options .standard { 4193 background: url(../images/post-formats.png) no-repeat -8px -8px; 4194 } 4195 4196 .post-format-options .image { 4197 background: url(../images/post-formats.png) no-repeat -40px -8px; 4198 } 4199 4200 .post-format-options .gallery { 4201 background: url(../images/post-formats.png) no-repeat -72px -8px; 4202 } 4203 4204 .post-format-options .audio { 4205 background: url(../images/post-formats.png) no-repeat -104px -8px; 4206 } 4207 4208 .post-format-options .video { 4209 background: url(../images/post-formats.png) no-repeat -136px -8px; 4210 } 4211 4212 .post-format-options .chat { 4213 background: url(../images/post-formats.png) no-repeat -168px -8px; 4214 } 4215 4216 .post-format-options .status { 4217 background: url(../images/post-formats.png) no-repeat -200px -8px; 4218 } 4219 4220 .post-format-options .aside { 4221 background: url(../images/post-formats.png) no-repeat -232px -8px; 4222 } 4223 4224 .post-format-options .quote { 4225 background: url(../images/post-formats.png) no-repeat -264px -8px; 4226 } 4227 4228 .post-format-options .link { 4229 background: url(../images/post-formats.png) no-repeat -296px -8px; 4230 } 4174 4231 } 4175 4232 -
trunk/wp-admin/edit-form-advanced.php
r23993 r24006 134 134 wp_enqueue_style( 'wp-mediaelement' ); 135 135 $post_format = get_post_format(); 136 137 if ( ! $post_format ) 136 $post_format_set_class = 'post-format-set'; 137 138 if ( ! $post_format ) { 138 139 $post_format = 'standard'; 140 if ( 'auto-draft' == $post->post_status ) 141 $post_format_set_class = ''; 142 } 139 143 140 144 $format_class = " class='wp-format-{$post_format}'"; … … 143 147 $all_post_formats = array( 144 148 'standard' => array ( 145 'description' => __( ' Add a title and use the editorto compose your post.' )149 'description' => __( 'Use the editor below to compose your post.' ) 146 150 ), 147 151 'image' => array ( 148 'description' => __( 'Select or upload an image to usefor your post.' )152 'description' => __( 'Select or upload an image for your post.' ) 149 153 ), 150 154 'gallery' => array ( … … 167 171 ), 168 172 'quote' => array ( 169 'description' => __( 'Copy a quotation into the box . Also add thesource and URL if you have them.' )173 'description' => __( 'Copy a quotation into the box below. Add a source and URL if you have them.' ) 170 174 ), 171 175 'aside' => array ( 172 'description' => __( ' An aside is a quick thought or side topic. Use the editor to compose one.' )176 'description' => __( 'Use the editor to share a quick thought or side topic.' ) 173 177 ) 174 178 ); … … 182 186 } 183 187 184 $post_format_options .= '<a ' . $class . ' href="?format=' . $slug . '" data-description="' . $attr['description'] . '" data-wp-format="' . $slug . '" title="' . ucfirst( sprintf( __( '%s Post' ), $slug ) ) . '"><div class="' . $slug . '"></div></a>';188 $post_format_options .= '<a ' . $class . ' href="?format=' . $slug . '" data-description="' . $attr['description'] . '" data-wp-format="' . $slug . '" title="' . ucfirst( $slug ) . '"><div class="' . $slug . '"></div><span class="post-format-title">' . ucfirst( $slug ) . '</span></a>'; 185 189 } 186 190 … … 359 363 ?> 360 364 361 <div class="wrap ">365 <div class="wrap <?php echo $post_format_set_class; ?>"> 362 366 <?php screen_icon(); ?> 363 367 <h2><?php … … 375 379 <p><?php _e("You have lost your connection with the server, and saving has been disabled. This message will vanish once you've reconnected."); ?></p> 376 380 </div> 381 <?php if ( ! empty( $post_format_options ) ) : ?> 382 <div class="post-format-options"> 383 <?php echo $post_format_options; ?> 384 </div> 385 <?php endif; ?> 377 386 <form name="post" action="post.php" method="post" id="post"<?php do_action('post_edit_form_tag'); ?>> 378 387 <?php wp_nonce_field($nonce_action); ?> … … 401 410 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 402 411 <div id="post-body-content"<?php echo $format_class; ?>> 403 404 <?php if ( ! empty( $post_format_options ) ) : ?>405 <div class="post-format-options">406 <span class="post-format-tip">Standard Post</span>407 <?php echo $post_format_options; ?>408 </div>409 <?php endif; ?>410 411 412 <?php if ( post_type_supports($post_type, 'title') ) { ?> 412 413 <div id="titlediv"> … … 425 426 $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status; 426 427 ?> 427 <div id="edit-slug-box" class="hide-if-no-js <?php if ( ! $has_sample_permalink ) echo ' hidden' ?>">428 <div id="edit-slug-box" class="hide-if-no-js"> 428 429 <?php 429 430 if ( $has_sample_permalink ) -
trunk/wp-admin/includes/post-formats.php
r23985 r24006 1 1 <?php 2 2 global $wp_embed; 3 3 4 $format_meta = get_post_format_meta( $post_ID ); 4 5 5 6 ?> 6 <div class="post-format- description"></div>7 <div class="post-format-change"><span class="icon <?php echo esc_attr( $post_format ); ?>"></span> <span class="post-format-description"><?php echo $all_post_formats[$post_format]['description']; ?></span> <a href="#"><?php _e('Change format'); ?></a></div> 7 8 <div class="post-formats-fields"> 8 9 … … 19 20 </div> 20 21 21 <?php22 $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 }27 ?>28 22 <div class="field wp-format-image"> 29 <div data-format="image" class="wp-format-media-holder hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>"> 23 <?php if ( ! empty( $format_meta['image'] ) ) : ?> 24 <div id="image-preview" class="wp-format-media-preview"> 25 <?php 26 if ( is_numeric( $format_meta['image'] ) ) { 27 $format_meta['image'] = absint( $format_meta['image'] ); 28 $image = wp_get_attachment_url( $format_meta['image'] ); 29 printf( '<img src="%s" alt="%s" />', esc_url( $image ), get_the_title( $format_meta['image'] ) ); 30 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $format_meta['image'] ) ) { 31 echo do_shortcode( $format_meta['image'] ); 32 } elseif ( ! preg_match( '#<[^>]+>#', $format_meta['image'] ) ) { 33 printf( '<img src="%s" alt="" />', esc_url( $format_meta['image'] ) ); 34 } else { 35 echo $format_meta['image']; 36 } 37 ?> 38 </div> 39 <?php endif ?> 40 <label for="wp_format_image"><?php 41 if ( current_user_can( 'unfiltered_html' ) ) 42 _e( 'Image HTML or URL' ); 43 else 44 _e( 'Image URL' ); 45 ?></label> 46 <textarea id="wp_format_image" type="text" name="_wp_format_image" class="widefat"><?php esc_html_e( $format_meta['image'] ); ?></textarea> 47 <div data-format="image" class="wp-format-media-holder hide-if-no-js"> 30 48 <a href="#" class="wp-format-media-select" 31 49 data-choose="<?php esc_attr_e( 'Choose an Image' ); ?>" 32 50 data-update="<?php esc_attr_e( 'Select Image' ); ?>"> 33 <?php 34 if ( $image ) 35 printf( '<img src="%s" alt="%s" />', esc_url( $image ), get_the_title( $format_meta['image'] ) ); 36 else 37 _e( 'Select / Upload Image' ); 38 ?> 51 <?php _e( 'Select / Upload Image' ); ?> 39 52 </a> 40 53 </div> 41 <input id="wp_format_image" type="hidden" name="_wp_format_image" value="<?php echo esc_attr( $format_meta['image'] ); ?>" />42 54 </div> 43 55 … … 47 59 </div> 48 60 49 <?php 50 $show_video_preview = ! empty( $format_meta['video'] ); 51 ?> 52 <div class="field wp-format-video<?php if ( $show_video_preview ) echo ' has-media-preview'; ?>"> 53 <?php if ( $show_video_preview ): ?> 61 <div class="field wp-format-video"> 62 <?php if ( ! empty( $format_meta['video'] ) ): ?> 54 63 <div id="video-preview" class="wp-format-media-preview"> 55 64 <?php … … 77 86 ?></label> 78 87 <textarea id="wp_format_video" type="text" name="_wp_format_video" class="widefat"><?php esc_html_e( $format_meta['video'] ); ?></textarea> 79 <div data-format="video" class="wp-format-media-holder hide-if-no-js <?php if ( ! $image ) echo ' empty'; ?>">88 <div data-format="video" class="wp-format-media-holder hide-if-no-js"> 80 89 <a href="#" class="wp-format-media-select" 81 90 data-choose="<?php esc_attr_e( 'Choose a Video' ); ?>" … … 86 95 </div> 87 96 88 <?php 89 $show_audio_preview = ! empty( $format_meta['audio'] ); 90 ?> 91 <div class="field wp-format-audio<?php if ( $show_audio_preview ) echo ' has-media-preview' ?>"> 92 <?php if ( $show_audio_preview ): ?> 97 <div class="field wp-format-audio"> 98 <?php if ( ! empty( $format_meta['audio'] ) ): ?> 93 99 <div id="audio-preview" class="wp-format-media-preview"> 94 100 <?php … … 115 121 _e( 'Audio URL' ); 116 122 ?></label> 117 <textarea id="wp_format_audio" name="_wp_format_audio" class="widefat"><?php esc_html_e( $format_meta['audio'] ); 118 ?></textarea> 119 <div data-format="audio" class="wp-format-media-holder hide-if-no-js<?php if ( empty( $format_meta['audio'] ) ) echo ' empty'; ?>"> 123 <textarea id="wp_format_audio" name="_wp_format_audio" class="widefat"><?php esc_html_e( $format_meta['audio'] ); ?></textarea> 124 <div data-format="audio" class="wp-format-media-holder hide-if-no-js"> 120 125 <a href="#" class="wp-format-media-select" data-choose="<?php esc_attr_e( 'Choose Audio' ); ?>" data-update="<?php esc_attr_e( 'Select Audio' ); ?>"> 121 126 <?php _e( 'Select Audio From Media Library' ) ?> -
trunk/wp-admin/js/post-formats.js
r23989 r24006 2 2 3 3 (function($) { 4 var container, mediaFrame, lastMimeType, lastMenu, mediaPreview, noUIFormats = ['standard', 'chat', 'status', 'aside', 'gallery']; 4 var container, mediaFrame, lastMimeType, lastMenu, mediaPreview, 5 noUIFormats = ['standard', 'chat', 'status', 'aside', 'gallery'], 6 $container = $( '.post-formats-fields' ); 5 7 6 8 function switchFormatClass( format ) { 7 container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/ , '' );9 container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/g, '' ); 8 10 container.addClass('wp-format-' + format); 9 11 } 10 12 13 function switchFormat ($this) { 14 var editor, body, 15 parent = $this.parent(), 16 format = $this.data('wp-format'), 17 description = $('.post-format-description'), 18 postTitle = $('#title'); 19 20 if ( typeof container === 'undefined' ) 21 container = $('#post-body-content'); 22 23 parent.slideUp().find('a.active').removeClass('active'); 24 $this.addClass('active'); 25 $('#post_format').val(format); 26 $('.post-format-change').show().find('span.icon').removeClass(postFormats.currentPostFormat).addClass(format); 27 // container.addClass('wp-format-set'); 28 29 if ( -1 < $.inArray( format, noUIFormats ) ) { 30 switchFormatClass( format ); // No slide 31 $container.hide(); 32 } else { 33 $container.slideUp( 200, function(){ 34 switchFormatClass( format ); 35 $container.slideDown( 400 ); 36 }); 37 } 38 39 postTitle.focus(); 40 41 if ( '' === postTitle.val() ) 42 $('#title-prompt-text').removeClass('screen-reader-text'); 43 44 // Update description line 45 description.html($this.data('description')); 46 47 if (description.not(':visible')) 48 description.slideDown('fast'); 49 50 if ( typeof tinymce != 'undefined' ) { 51 editor = tinymce.get('content'); 52 53 if ( editor ) { 54 body = editor.getBody(); 55 body.className = body.className.replace( /\bpost-format-[^ ]+/, '' ); 56 editor.dom.addClass( body, 'post-format-' + format ); 57 } 58 } 59 60 postFormats.currentPostFormat = format; 61 } 62 11 63 $(function(){ 12 var $container = $( '.post-formats-fields' ); 64 65 $('.post-format-change a').click(function () { 66 $('.post-formats-fields, .post-format-change').slideUp(); 67 $('.post-format-options').slideDown(); 68 return false; 69 }); 13 70 14 71 // Post formats selection 15 72 $('.post-format-options').on( 'click', 'a', function(e){ 16 73 e.preventDefault(); 17 var $this = $(this), editor, body, 18 parent = $this.parent(), 19 format = $this.data('wp-format'), 20 description = $('.post-format-description'); 21 22 if ( typeof container === 'undefined' ) 23 container = $('#post-body-content'); 24 25 // Already on this post format. Bail. 26 if ( format === postFormats.currentPostFormat ) 27 return; 28 29 parent.find('a.active').removeClass('active'); 30 $this.addClass('active'); 31 $('#icon-edit').removeClass(postFormats.currentPostFormat).addClass(format); 32 $('#post_format').val(format); 33 34 if ( -1 < $.inArray( format, noUIFormats ) && -1 < $.inArray( postFormats.currentPostFormat, noUIFormats ) ) { 35 switchFormatClass( format ); // No slide 36 } else { 37 $container.slideUp( 200, function(){ 38 switchFormatClass( format ); 39 $container.slideDown( 400 ); 40 }); 41 } 42 43 $('#title').focus(); 44 45 // Update description line 46 description.html($this.data('description')); 47 48 if (description.not(':visible')) 49 description.slideDown('fast'); 50 51 if ( typeof tinymce != 'undefined' ) { 52 editor = tinymce.get('content'); 53 54 if ( editor ) { 55 body = editor.getBody(); 56 body.className = body.className.replace( /\bpost-format-[^ ]+/, '' ); 57 editor.dom.addClass( body, 'post-format-' + format ); 58 } 59 } 60 61 postFormats.currentPostFormat = format; 62 }).on('mouseenter focusin', 'a', function () { 63 $('.post-format-tip').html( $(this).prop('title') ); 64 }).on('mouseleave focusout', 'a', function () { 65 $('.post-format-tip').html( $('.post-format-options a.active').prop('title') ); 74 switchFormat($(this)); 66 75 }); 67 76 … … 69 78 $('.wp-format-media-select').click(function (event) { 70 79 event.preventDefault(); 71 var $el = $(this), $holder, $field, mime = 'image', menu = '',80 var $el = $(this), mime, 72 81 $holder = $el.closest('.wp-format-media-holder'), 73 82 $field = $( '#wp_format_' + $holder.data('format') ); 74 83 75 switch ( $holder.data('format') ) { 76 case 'audio': 77 mime = 'audio'; 78 break; 79 case 'video': 80 mime = 'video'; 81 break; 82 } 84 mime = $holder.data('format'); 83 85 84 86 // If the media frame already exists, reopen it. 85 if ( mediaFrame && lastMimeType === mime && lastMenu === menu) {87 if ( mediaFrame && lastMimeType === mime ) { 86 88 mediaFrame.open(); 87 89 return; … … 89 91 90 92 lastMimeType = mime; 91 lastMenu = menu;92 93 93 94 // Create the media frame. … … 95 96 // Set the title of the modal. 96 97 title: $el.data('choose'), 97 98 // Set the menu sidebar of the modal, if applicable99 toolbar: menu,100 98 101 99 // Tell the modal to show only items matching the current mime type. … … 143 141 mediaFrame.on( 'select', function () { 144 142 // Grab the selected attachment. 145 var attachment = mediaFrame.state().get('selection').first().toJSON();143 var w = 0, h = 0, html, attachment = mediaFrame.state().get('selection').first().toJSON(); 146 144 147 145 if ( 0 === attachment.mime.indexOf('audio') ) { … … 158 156 mediaPreview(attachment); 159 157 } else { 158 html = wp.media.string.image({}, attachment); 160 159 // set the hidden input's value 161 $field.val(attachment.id); 162 // Show the image in the placeholder 163 $el.html('<img src="' + attachment.url + '" />'); 164 $holder.removeClass('empty').show(); 160 $field.val(html); 161 $('#image-preview').remove(); 162 if ( attachment.width ) 163 w = attachment.width > 600 ? 600 : attachment.width; 164 if ( attachment.height ) 165 h = attachment.height; 166 if ( w < attachment.width ) 167 h = Math.round( ( h * w ) / attachment.width ); 168 $holder.parent().prepend( ['<div id="image-preview" class="wp-format-media-preview">', 169 '<img src="', attachment.url, '"', 170 w ? ' width="' + w + '"' : '', 171 h ? ' height="' + h + '"' : '', 172 ' />', 173 '</div>'].join('') ); 165 174 } 166 175 }); -
trunk/wp-includes/js/media-editor.js
r23998 r24006 192 192 classes = props.classes || []; 193 193 194 img.src = props.url;194 img.src = attachment.url; 195 195 _.extend( img, _.pick( props, 'width', 'height', 'alt' ) ); 196 196 -
trunk/wp-includes/media.php
r24003 r24006 2407 2407 2408 2408 if ( ! empty( $meta['image'] ) ) { 2409 $post->format_content = sprintf( $link_fmt, wp_get_attachment_image( $meta['image'], $attached_size ) ); 2409 if ( is_numeric( $meta['image'] ) ) 2410 $image = wp_get_attachment_image( absint( $meta['image'] ), $attached_size ); 2411 elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $meta['image'] ) ) 2412 $image = do_shortcode( $meta['image'] ); 2413 elseif ( ! preg_match( '#<[^>]+>#', $meta['image'] ) ) 2414 $image = sprintf( '<img src="%s" alt="" />', esc_url( $meta['image'] ) ); 2415 else 2416 $image = $meta['image']; 2417 2418 $post->format_content = sprintf( $link_fmt, $image ); 2410 2419 return $post->format_content; 2411 2420 }
Note: See TracChangeset
for help on using the changeset viewer.