Make WordPress Core


Ignore:
Timestamp:
12/05/2012 10:29:24 AM (13 years ago)
Author:
markjaquith
Message:

Intelligently make media fields readonly when the user cannot update or do anything with them. props koopersmith, helenyhou, nacin. fixes #22613

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r23061 r23072  
    16591659            <# } #>
    16601660        </div>
    1661         <# if ( data.describe ) { #>
     1661        <#
     1662        var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
     1663        if ( data.describe ) { #>
    16621664            <# if ( 'image' === data.type ) { #>
    16631665                <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"
    1664                     placeholder="<?php esc_attr_e('Describe this image&hellip;'); ?>" />
     1666                    placeholder="<?php esc_attr_e('Describe this image&hellip;'); ?>" {{ maybeReadOnly }} />
    16651667            <# } else { #>
    16661668                <input type="text" value="{{ data.title }}" class="describe" data-setting="title"
     
    16711673                    <# } else { #>
    16721674                        placeholder="<?php esc_attr_e('Describe this media file&hellip;'); ?>"
    1673                     <# } #> />
     1675                    <# } #> {{ maybeReadOnly }} />
    16741676            <# } #>
    16751677        <# } #>
     
    17141716        </div>
    17151717
    1716         <# if ( 'image' === data.type ) { #>
     1718        <#
     1719        var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
     1720        if ( 'image' === data.type ) { #>
    17171721            <label class="setting" data-setting="title">
    17181722                <span><?php _e('Title'); ?></span>
    1719                 <input type="text" value="{{ data.title }}" />
     1723                <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} />
    17201724            </label>
    17211725            <label class="setting" data-setting="caption">
    17221726                <span><?php _e('Caption'); ?></span>
    1723                 <textarea
     1727                <textarea {{ maybeReadOnly }}
    17241728                    placeholder="<?php esc_attr_e('Describe this image&hellip;'); ?>"
    17251729                    >{{ data.caption }}</textarea>
     
    17271731            <label class="setting" data-setting="alt">
    17281732                <span><?php _e('Alt Text'); ?></span>
    1729                 <input type="text" value="{{ data.alt }}" />
     1733                <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
    17301734            </label>
    17311735        <# } else { #>
    17321736            <label class="setting" data-setting="title">
    17331737                <span><?php _e('Title'); ?></span>
    1734                 <input type="text" value="{{ data.title }}"
     1738                <input type="text" value="{{ data.title }}" {{ maybeReadOnly }}
    17351739                <# if ( 'video' === data.type ) { #>
    17361740                    placeholder="<?php esc_attr_e('Describe this video&hellip;'); ?>"
Note: See TracChangeset for help on using the changeset viewer.