From c95ff91fe71a619c05a47fe5fa6565c6d66266f0 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 4 Jan 2013 08:02:16 +0000 Subject: [PATCH] Media: Restore 3.4 behavior by consulting the old-school DB options for default align, size, and link properties. This restores linking to media files as the default, over attachment pages. This 'default' cannot currently be changed by a user setting (per 3.4 behavior), due to the default database schema. see #22841, for trunk. git-svn-id: http://core.svn.wordpress.org/trunk@23262 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-editor.js | 9 +++++---- wp-includes/js/media-views.js | 7 ++++--- wp-includes/media-template.php | 16 ++++++++-------- wp-includes/media.php | 7 +++++++ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/wp-includes/js/media-editor.js b/wp-includes/js/media-editor.js index a866e4716a..80494ba17f 100644 --- a/wp-includes/js/media-editor.js +++ b/wp-includes/js/media-editor.js @@ -9,7 +9,8 @@ // outputting the proper object format based on the // attachment's type. props: function( props, attachment ) { - var link, linkUrl, size, sizes, fallbacks; + var link, linkUrl, size, sizes, fallbacks, + defaultProps = wp.media.view.settings.defaultProps; // Final fallbacks run after all processing has been completed. fallbacks = function( props ) { @@ -29,8 +30,8 @@ if ( 'image' === props.type ) { props = _.defaults( props || {}, { - align: getUserSetting( 'align', 'none' ), - size: getUserSetting( 'imgsize', 'medium' ), + align: defaultProps.align || getUserSetting( 'align', 'none' ), + size: defaultProps.size || getUserSetting( 'imgsize', 'medium' ), url: '', classes: [] }); @@ -42,7 +43,7 @@ props.title = props.title || attachment.title; - link = props.link || getUserSetting( 'urlbutton', 'post' ); + link = props.link || defaultProps.link || getUserSetting( 'urlbutton', 'file' ); if ( 'file' === link ) linkUrl = attachment.url; else if ( 'post' === link ) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 733466c867..1050420044 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -438,11 +438,12 @@ }, resetDisplays: function() { + var defaultProps = media.view.settings.defaultProps; this._displays = []; this._defaultDisplaySettings = { - align: getUserSetting( 'align', 'none' ), - size: getUserSetting( 'imgsize', 'medium' ), - link: getUserSetting( 'urlbutton', 'post' ) + align: defaultProps.align || getUserSetting( 'align', 'none' ), + size: defaultProps.size || getUserSetting( 'imgsize', 'medium' ), + link: defaultProps.link || getUserSetting( 'urlbutton', 'file' ) }; }, diff --git a/wp-includes/media-template.php b/wp-includes/media-template.php index 909ddfe5ec..7e79efdaf4 100644 --- a/wp-includes/media-template.php +++ b/wp-includes/media-template.php @@ -291,12 +291,12 @@ function wp_print_media_templates() { - - + @@ -347,12 +347,12 @@ function wp_print_media_templates() { data-user-setting="urlbutton" <# } #>> - - + diff --git a/wp-includes/media.php b/wp-includes/media.php index 2f47358d2d..705b36c351 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1454,6 +1454,12 @@ function wp_enqueue_media( $args = array() ) { $tabs = apply_filters( 'media_upload_tabs', $tabs ); unset( $tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library'] ); + $props = array( + 'link' => get_option( 'image_default_link_type' ), // db default is 'file' + 'align' => get_option( 'image_default_align' ), // empty default + 'size' => get_option( 'image_default_size' ), // empty default + ); + $settings = array( 'tabs' => $tabs, 'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ), @@ -1465,6 +1471,7 @@ function wp_enqueue_media( $args = array() ) { 'post' => array( 'id' => 0, ), + 'defaultProps' => $props, ); $post = null;