From 88ca7797d1e1ceb02c841d69c16e0665297f20c7 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 2 Jul 2008 18:41:11 +0000 Subject: [PATCH] Image captions from azaozz. see #6812 git-svn-id: http://svn.automattic.com/wordpress/trunk@8239 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/gears-manifest.php | 2 +- wp-admin/includes/media.php | 19 +++ wp-admin/js/editor.js | 4 +- wp-admin/js/media-upload.js | 1 + wp-content/themes/classic/style.css | 42 +++++ wp-content/themes/default/style.css | 35 ++++ wp-includes/js/tinymce/langs/wp-langs.php | 1 + .../plugins/wpeditimage/editor_plugin.js | 132 ++++++++++----- .../plugins/wpeditimage/js/editimage.js | 153 +++++++++++++----- .../advanced/skins/wp_theme/content.css | 6 +- wp-includes/js/tinymce/wordpress.css | 32 +++- wp-includes/media.php | 25 +++ wp-includes/script-loader.php | 6 +- 13 files changed, 365 insertions(+), 93 deletions(-) diff --git a/wp-admin/gears-manifest.php b/wp-admin/gears-manifest.php index a6236f81cd..0e887a831c 100644 --- a/wp-admin/gears-manifest.php +++ b/wp-admin/gears-manifest.php @@ -64,7 +64,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' ); ?> { "betaManifestVersion" : 1, -"version" : "_20080626", +"version" : "_20080701", "entries" : [ diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 99f2bbd2bd..80910d6c24 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -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) { ?>