Intelligently make media fields readonly when the user cannot update or do anything with them. props koopersmith, helenyhou, nacin. fixes #22613
git-svn-id: http://core.svn.wordpress.org/trunk@23072 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1543,6 +1543,10 @@
|
||||
multiple: options.multiple ? 'reset' : false,
|
||||
editable: true,
|
||||
|
||||
// If the user isn't allowed to edit fields,
|
||||
// can they still edit it locally?
|
||||
allowLocalEdits: true,
|
||||
|
||||
// Show the attachment display settings.
|
||||
displaySettings: true,
|
||||
// Update user settings when users adjust the
|
||||
@@ -2840,6 +2844,9 @@
|
||||
options.can.save = !! options.nonces.update;
|
||||
}
|
||||
|
||||
if ( this.controller.state().get('allowLocalEdits') )
|
||||
options.allowLocalEdits = true;
|
||||
|
||||
this.views.detach();
|
||||
this.$el.html( this.template( options ) );
|
||||
|
||||
|
||||
@@ -1658,10 +1658,12 @@ function wp_print_media_templates() {
|
||||
<a class="check" href="#" title="<?php _e('Deselect'); ?>"><div class="media-modal-icon"></div></a>
|
||||
<# } #>
|
||||
</div>
|
||||
<# if ( data.describe ) { #>
|
||||
<#
|
||||
var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
|
||||
if ( data.describe ) { #>
|
||||
<# if ( 'image' === data.type ) { #>
|
||||
<input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"
|
||||
placeholder="<?php esc_attr_e('Describe this image…'); ?>" />
|
||||
placeholder="<?php esc_attr_e('Describe this image…'); ?>" {{ maybeReadOnly }} />
|
||||
<# } else { #>
|
||||
<input type="text" value="{{ data.title }}" class="describe" data-setting="title"
|
||||
<# if ( 'video' === data.type ) { #>
|
||||
@@ -1670,7 +1672,7 @@ function wp_print_media_templates() {
|
||||
placeholder="<?php esc_attr_e('Describe this audio file…'); ?>"
|
||||
<# } else { #>
|
||||
placeholder="<?php esc_attr_e('Describe this media file…'); ?>"
|
||||
<# } #> />
|
||||
<# } #> {{ maybeReadOnly }} />
|
||||
<# } #>
|
||||
<# } #>
|
||||
</script>
|
||||
@@ -1713,25 +1715,27 @@ function wp_print_media_templates() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<# if ( 'image' === data.type ) { #>
|
||||
<#
|
||||
var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
|
||||
if ( 'image' === data.type ) { #>
|
||||
<label class="setting" data-setting="title">
|
||||
<span><?php _e('Title'); ?></span>
|
||||
<input type="text" value="{{ data.title }}" />
|
||||
<input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
|
||||
</label>
|
||||
<label class="setting" data-setting="caption">
|
||||
<span><?php _e('Caption'); ?></span>
|
||||
<textarea
|
||||
<textarea {{ maybeReadOnly }}
|
||||
placeholder="<?php esc_attr_e('Describe this image…'); ?>"
|
||||
>{{ data.caption }}</textarea>
|
||||
</label>
|
||||
<label class="setting" data-setting="alt">
|
||||
<span><?php _e('Alt Text'); ?></span>
|
||||
<input type="text" value="{{ data.alt }}" />
|
||||
<input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
|
||||
</label>
|
||||
<# } else { #>
|
||||
<label class="setting" data-setting="title">
|
||||
<span><?php _e('Title'); ?></span>
|
||||
<input type="text" value="{{ data.title }}"
|
||||
<input type="text" value="{{ data.title }}" {{ maybeReadOnly }}
|
||||
<# if ( 'video' === data.type ) { #>
|
||||
placeholder="<?php esc_attr_e('Describe this video…'); ?>"
|
||||
<# } else if ( 'audio' === data.type ) { #>
|
||||
|
||||
Reference in New Issue
Block a user