From 9e673c7eee29c5d0c8a0dcd11b46402ebb4a9ecf Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 21 Sep 2014 09:55:08 +0000 Subject: [PATCH] Add 'image_add_caption_text' filter for changing the pre-parse caption text before output to the editor. props collinsinternet, DrewAPicture. fixes #29607. git-svn-id: https://develop.svn.wordpress.org/trunk@29753 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/media.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 31acad303f..8294a526a9 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -158,6 +158,21 @@ function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel = */ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) { + /** + * Filter the caption text. + * + * Note: If the caption text is empty, the caption shortcode will not be appended + * to the image HTML when inserted into the editor. + * + * Passing an empty value also prevents the 'image_add_caption_shortcode' filter + * from being evaluated at the end of {@see image_add_caption()}. + * + * @since 4.1.0 + * + * @param string $caption The original caption text. + */ + $caption = apply_filters( 'image_add_caption_text', $caption ); + /** * Filter whether to disable captions. *