Changeset 20174 for trunk/wp-admin/includes/media.php
- Timestamp:
- 03/14/2012 09:53:11 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r20168 r20174 145 145 $id = ( 0 < (int) $id ) ? 'attachment_' . $id : ''; 146 146 147 if ( ! preg_match( '/width= "([0-9]+)/', $html, $matches ) )147 if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) ) 148 148 return $html; 149 149 150 150 $width = $matches[1]; 151 151 152 // look only for html tags with attributes153 $caption = preg_replace_callback( '/<[a-zA-Z0-9]+ [^<>]+>/', '_cleanup_image_add_caption', $caption );154 $caption = str_replace( '"', '"', $caption);152 $caption = str_replace( array("\r\n", "\r"), "\n", $caption); 153 $caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption ); 154 $caption = preg_replace( '/\n+/', '<br />', str_replace('"', '"', $caption) ); 155 155 156 156 $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); … … 168 168 function _cleanup_image_add_caption($str) { 169 169 if ( isset($str[0]) ) { 170 // remove any line breaks from inside the tags 171 $s = preg_replace( '/[\r\n\t]+/', ' ', $str[0]); 170 172 // look for single quotes inside html attributes (for example in title) 171 $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $s tr[0]);173 $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $s ); 172 174 return str_replace( '"', "'", $s ); 173 175 } … … 1543 1545 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> 1544 1546 if ( f.caption.value ) { 1545 caption = f.caption.value.replace(/<[a-zA-Z0-9]+ [^<>]+>/g, function(a){ 1546 a = a.replace(/="[^"]+"/, function(b){ 1547 caption = f.caption.value.replace(/\r\n|\r/g, '\n'); 1548 caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){ 1549 a = a.replace(/[\r\n\t]+/, ' ').replace(/="[^"]+"/, function(b){ 1547 1550 return b.replace(/'/g, '''); 1548 1551 }); … … 1550 1553 }); 1551 1554 1552 caption = caption.replace(/ "/g, '"');1555 caption = caption.replace(/\n+/g, '<br />').replace(/"/g, '"'); 1553 1556 } 1554 1557 <?php } ?>
Note: See TracChangeset
for help on using the changeset viewer.