Changeset 29206 for trunk/src/wp-admin/includes/media.php
- Timestamp:
- 07/17/2014 09:13:53 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r29029 r29206 181 181 $caption = str_replace( array("\r\n", "\r"), "\n", $caption); 182 182 $caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption ); 183 // convert any remaining line breaks to <br> 183 184 // Convert any remaining line breaks to <br>. 184 185 $caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '<br />', $caption ); 185 186 … … 209 210 */ 210 211 function _cleanup_image_add_caption( $matches ) { 211 // remove any line breaks from inside the tags212 // Remove any line breaks from inside the tags. 212 213 return preg_replace( '/[\r\n\t]+/', ' ', $matches[0] ); 213 214 } … … 318 319 $content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] ); 319 320 320 // use image exif/iptc data for title and caption defaults if possible321 // Use image exif/iptc data for title and caption defaults if possible. 321 322 } elseif ( $image_meta = @wp_read_image_metadata( $file ) ) { 322 323 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) … … 379 380 $content = ''; 380 381 381 // use image exif/iptc data for title and caption defaults if possible382 // Use image exif/iptc data for title and caption defaults if possible. 382 383 if ( $image_meta = @wp_read_image_metadata($file) ) { 383 384 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) … … 390 391 $title = $desc; 391 392 392 // Construct the attachment array 393 // Construct the attachment array. 393 394 $attachment = array_merge( array( 394 395 'post_mime_type' => $type, … … 635 636 if ( $image_alt != get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ) { 636 637 $image_alt = wp_strip_all_tags( $image_alt, true ); 637 // update_meta expects slashed 638 639 // Update_meta expects slashed. 638 640 update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); 639 641 } … … 808 810 function media_sideload_image( $file, $post_id, $desc = null ) { 809 811 if ( ! empty( $file ) ) { 810 // Set variables for storage 811 // fix file filename for query strings 812 // Set variables for storage, fix file filename for query strings. 812 813 preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches ); 813 814 $file_array['name'] = basename( $matches[0] ); 814 // Download file to temp location 815 816 // Download file to temp location. 815 817 $file_array['tmp_name'] = download_url( $file ); 816 818 … … 820 822 } 821 823 822 // do the validation and storage stuff824 // Do the validation and storage stuff. 823 825 $id = media_handle_sideload( $file_array, $post_id, $desc ); 824 // If error storing permanently, unlink 826 827 // If error storing permanently, unlink. 825 828 if ( is_wp_error( $id ) ) { 826 829 @unlink( $file_array['tmp_name'] ); … … 831 834 } 832 835 833 // Finally check to make sure the file has been saved, then return the html836 // Finally check to make sure the file has been saved, then return the HTML. 834 837 if ( ! empty( $src ) ) { 835 838 $alt = isset( $desc ) ? esc_attr( $desc ) : ''; … … 944 947 $checked = ''; 945 948 946 // is this size selectable?949 // Is this size selectable? 947 950 $enabled = ( $downsize[3] || 'full' == $size ); 948 951 $css_id = "image-size-{$size}-{$post->ID}"; 949 // if this size is the default but that's not available, don't select it 952 953 // If this size is the default but that's not available, don't select it. 950 954 if ( $size == $check ) { 951 955 if ( $enabled ) … … 954 958 $check = ''; 955 959 } elseif ( !$check && $enabled && 'thumbnail' != $size ) { 956 // if $check is not enabled, default to the first available size that's bigger than a thumbnail 960 /* 961 * If $check is not enabled, default to the first available size 962 * that's bigger than a thumbnail. 963 */ 957 964 $check = $size; 958 965 $checked = " checked='checked'"; … … 962 969 963 970 $html .= "<label for='{$css_id}'>$label</label>"; 964 // only show the dimensions if that choice is available 971 972 // Only show the dimensions if that choice is available. 965 973 if ( $enabled ) 966 974 $html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d × %d)", $downsize[1], $downsize[2] ). "</label>"; … … 1010 1018 1011 1019 function wp_caption_input_textarea($edit_post) { 1012 // post data is already escaped1020 // Post data is already escaped. 1013 1021 $name = "attachments[{$edit_post->ID}][post_excerpt]"; 1014 1022 … … 1473 1481 elseif ( $field['input'] == 'textarea' ) { 1474 1482 if ( 'post_content' == $id && user_can_richedit() ) { 1475 // sanitize_post() skips the post_content when user_can_richedit1483 // Sanitize_post() skips the post_content when user_can_richedit. 1476 1484 $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); 1477 1485 } 1478 // post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit()1486 // Post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit(). 1479 1487 $item .= "<textarea id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>'; 1480 1488 } else { … … 1622 1630 elseif ( $field['input'] == 'textarea' ) { 1623 1631 if ( 'post_content' == $id && user_can_richedit() ) { 1624 // sanitize_post() skips the post_content when user_can_richedit 1632 // sanitize_post() skips the post_content when user_can_richedit. 1625 1633 $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); 1626 1634 } … … 2853 2861 if ( ! empty( $list ) ) { 2854 2862 $metadata[$key] = reset( $list ); 2855 // fix bug in byte stream analysis2863 // Fix bug in byte stream analysis. 2856 2864 if ( 'terms_of_use' === $key && 0 === strpos( $metadata[$key], 'yright notice.' ) ) 2857 2865 $metadata[$key] = 'Cop' . $metadata[$key];
Note: See TracChangeset
for help on using the changeset viewer.