From 493572fd094956e3eccec3a1ddc40ccb0dd7b00e Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Wed, 21 Nov 2012 14:27:22 +0000 Subject: [PATCH] Media: Backwards compatibility for the disable_captions filter. see #22186, #21390. git-svn-id: https://develop.svn.wordpress.org/trunk@22761 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/js/media-upload.js | 12 +++++++----- wp-includes/media.php | 11 +++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js index 75e05ef4db..7d2fd34047 100644 --- a/wp-admin/js/media-upload.js +++ b/wp-admin/js/media-upload.js @@ -118,8 +118,6 @@ var tb_position; }); if ( attachment ) { - attachment = attachment.toJSON(); - _.extend( props, { title: attachment.title || attachment.filename, linkUrl: linkToUrl( props, attachment ), @@ -153,8 +151,6 @@ var tb_position; }); if ( attachment ) { - attachment = attachment.toJSON(); - classes.push( 'wp-image-' + attachment.id ); sizes = attachment.sizes; @@ -397,7 +393,13 @@ var tb_position; // Reset the attachment details. delete details[ attachment.cid ]; - if ( 'image' === attachment.get('type') ) + attachment = attachment.toJSON(); + + // If captions are disabled, clear the caption. + if ( ! wp.media.view.settings.captions ) + delete attachment.caption; + + if ( 'image' === attachment.type ) this.insert( wp.media.string.image( detail, attachment ) + ' ' ); else this.insert( wp.media.string.link( detail, attachment ) + ' ' ); diff --git a/wp-includes/media.php b/wp-includes/media.php index 1e5cc377d4..77a60f4eaf 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1327,6 +1327,7 @@ function wp_enqueue_media( $args = array() ) { 'tabs' => $tabs, 'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ), 'mimeTypes' => wp_list_pluck( get_post_mime_types(), 0 ), + 'captions' => ! apply_filters( 'disable_captions', '' ), ); $post = null; @@ -1691,10 +1692,12 @@ function wp_print_media_templates( $attachment ) { -