Media: Backwards compatibility for the disable_captions filter. see #22186, #21390.

git-svn-id: http://core.svn.wordpress.org/trunk@22761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-21 14:27:22 +00:00
parent 4d01db3f0a
commit e0ebe09802
2 changed files with 14 additions and 9 deletions

View File

@ -118,8 +118,6 @@ var tb_position;
}); });
if ( attachment ) { if ( attachment ) {
attachment = attachment.toJSON();
_.extend( props, { _.extend( props, {
title: attachment.title || attachment.filename, title: attachment.title || attachment.filename,
linkUrl: linkToUrl( props, attachment ), linkUrl: linkToUrl( props, attachment ),
@ -153,8 +151,6 @@ var tb_position;
}); });
if ( attachment ) { if ( attachment ) {
attachment = attachment.toJSON();
classes.push( 'wp-image-' + attachment.id ); classes.push( 'wp-image-' + attachment.id );
sizes = attachment.sizes; sizes = attachment.sizes;
@ -397,7 +393,13 @@ var tb_position;
// Reset the attachment details. // Reset the attachment details.
delete details[ attachment.cid ]; 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 ) + ' ' ); this.insert( wp.media.string.image( detail, attachment ) + ' ' );
else else
this.insert( wp.media.string.link( detail, attachment ) + ' ' ); this.insert( wp.media.string.link( detail, attachment ) + ' ' );

View File

@ -1327,6 +1327,7 @@ function wp_enqueue_media( $args = array() ) {
'tabs' => $tabs, 'tabs' => $tabs,
'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ), 'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ),
'mimeTypes' => wp_list_pluck( get_post_mime_types(), 0 ), 'mimeTypes' => wp_list_pluck( get_post_mime_types(), 0 ),
'captions' => ! apply_filters( 'disable_captions', '' ),
); );
$post = null; $post = null;
@ -1691,10 +1692,12 @@ function wp_print_media_templates( $attachment ) {
<img src="{{ data.model.url }}" draggable="false" /> <img src="{{ data.model.url }}" draggable="false" />
</div> </div>
<label class="setting caption"> <?php if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
<span><?php _e('Caption'); ?></span> <label class="setting caption">
<textarea data-setting="caption" /> <span><?php _e('Caption'); ?></span>
</label> <textarea data-setting="caption" />
</label>
<?php endif; ?>
<label class="setting alt-text"> <label class="setting alt-text">
<span><?php _e('Alt Text'); ?></span> <span><?php _e('Alt Text'); ?></span>