mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Image captions from azaozz. see #6812
git-svn-id: https://develop.svn.wordpress.org/trunk@8239 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -64,7 +64,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
|
||||
?>
|
||||
{
|
||||
"betaManifestVersion" : 1,
|
||||
"version" : "<?php echo $man_version; ?>_20080626",
|
||||
"version" : "<?php echo $man_version; ?>_20080701",
|
||||
"entries" : [
|
||||
<?php echo $defaults; ?>
|
||||
|
||||
|
||||
@@ -62,6 +62,25 @@ function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = fal
|
||||
return $html;
|
||||
}
|
||||
|
||||
function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
|
||||
|
||||
if ( empty($alt) ) return $html;
|
||||
$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
|
||||
|
||||
preg_match( '/width="([0-9]+)/', $html, $matches );
|
||||
if ( ! isset($matches[1]) ) return $html;
|
||||
$width = $matches[1];
|
||||
|
||||
$html = preg_replace( '/align[^\s\'"]+\s?/', '', $html );
|
||||
if ( empty($align) ) $align = 'none';
|
||||
|
||||
$shcode = '[wp_caption id="' . $id . '" align="align' . $align
|
||||
. '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/wp_caption]';
|
||||
|
||||
return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
|
||||
}
|
||||
add_filter( 'image_send_to_editor', 'image_add_caption', 20, 7 );
|
||||
|
||||
function media_send_to_editor($html) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -52,6 +52,7 @@ switchEditors = {
|
||||
// Fix some block element newline issues
|
||||
content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
|
||||
content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
|
||||
content = content.replace(new RegExp('\\s*\\[wp_caption([^\\[]+)\\[/wp_caption\\]\\s*', 'gi'), '\n\n[wp_caption$1[/wp_caption]\n\n');
|
||||
|
||||
var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
|
||||
content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
|
||||
@@ -69,7 +70,7 @@ switchEditors = {
|
||||
|
||||
// Trim whitespace
|
||||
content = content.replace(new RegExp('^\\s*', ''), '');
|
||||
content = content.replace(new RegExp('\\s*$', ''), '');
|
||||
content = content.replace(new RegExp('[\\s\\u00a0]*$', ''), '');
|
||||
|
||||
// put back the line breaks in pre|script
|
||||
content = content.replace(/<wp_temp>/g, '\n');
|
||||
@@ -164,6 +165,7 @@ switchEditors = {
|
||||
pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
|
||||
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
|
||||
pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
|
||||
pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[wp_caption([^\\[]+)\\[/wp_caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[wp_caption$1[/wp_caption]');
|
||||
// pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 ');
|
||||
|
||||
// Fix the pre|script tags
|
||||
|
||||
@@ -6,6 +6,7 @@ function send_to_editor(h) {
|
||||
ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
|
||||
|
||||
ed.execCommand('mceInsertContent', false, h);
|
||||
ed.execCommand('mceCleanup');
|
||||
} else
|
||||
edInsertContent(edCanvas, h);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user