Make WordPress Core


Ignore:
Timestamp:
10/10/2012 11:32:48 PM (13 years ago)
Author:
koopersmith
Message:

Caption editing in the media modal library.

  • Adds a describe option to the workflow controller to support inline caption editing.
  • For images, descriptions are mapped to the caption attribute.
  • For other media items, descriptions are mapped to the title attribute.
  • Descriptions are saved when the textarea's change event fires (i.e. when the textarea is blurred).

fixes #21807, see #21390.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ajax-actions.php

    r22129 r22173  
    18211821    wp_send_json_success( $posts );
    18221822}
     1823
     1824/**
     1825 * Save attachment attributes.
     1826 *
     1827 * @since 3.5.0
     1828 */
     1829function wp_ajax_save_attachment() {
     1830    if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) )
     1831        wp_send_json_error();
     1832
     1833    if ( ! $id = absint( $_REQUEST['id'] ) )
     1834        wp_send_json_error();
     1835
     1836    if ( ! current_user_can( 'edit_post', $id ) )
     1837        wp_send_json_error();
     1838
     1839    $changes = $_REQUEST['changes'];
     1840    $args    = array();
     1841
     1842    if ( $changes['title'] )
     1843        $args['post_title'] = $changes['title'];
     1844
     1845    if ( $changes['caption'] )
     1846        $args['post_excerpt'] = $changes['caption'];
     1847
     1848    if ( $args )
     1849        wp_update_post( array_merge( $args, array( 'ID' => $id ) ) );
     1850
     1851    wp_send_json_success();
     1852}
Note: See TracChangeset for help on using the changeset viewer.