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
This commit is contained in:
Andrew Nacin 2013-01-04 08:02:16 +00:00
parent da06cf3e2d
commit c95ff91fe7
4 changed files with 24 additions and 15 deletions

View File

@ -9,7 +9,8 @@
// outputting the proper object format based on the // outputting the proper object format based on the
// attachment's type. // attachment's type.
props: function( props, attachment ) { 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. // Final fallbacks run after all processing has been completed.
fallbacks = function( props ) { fallbacks = function( props ) {
@ -29,8 +30,8 @@
if ( 'image' === props.type ) { if ( 'image' === props.type ) {
props = _.defaults( props || {}, { props = _.defaults( props || {}, {
align: getUserSetting( 'align', 'none' ), align: defaultProps.align || getUserSetting( 'align', 'none' ),
size: getUserSetting( 'imgsize', 'medium' ), size: defaultProps.size || getUserSetting( 'imgsize', 'medium' ),
url: '', url: '',
classes: [] classes: []
}); });
@ -42,7 +43,7 @@
props.title = props.title || attachment.title; props.title = props.title || attachment.title;
link = props.link || getUserSetting( 'urlbutton', 'post' ); link = props.link || defaultProps.link || getUserSetting( 'urlbutton', 'file' );
if ( 'file' === link ) if ( 'file' === link )
linkUrl = attachment.url; linkUrl = attachment.url;
else if ( 'post' === link ) else if ( 'post' === link )

View File

@ -438,11 +438,12 @@
}, },
resetDisplays: function() { resetDisplays: function() {
var defaultProps = media.view.settings.defaultProps;
this._displays = []; this._displays = [];
this._defaultDisplaySettings = { this._defaultDisplaySettings = {
align: getUserSetting( 'align', 'none' ), align: defaultProps.align || getUserSetting( 'align', 'none' ),
size: getUserSetting( 'imgsize', 'medium' ), size: defaultProps.size || getUserSetting( 'imgsize', 'medium' ),
link: getUserSetting( 'urlbutton', 'post' ) link: defaultProps.link || getUserSetting( 'urlbutton', 'file' )
}; };
}, },

View File

@ -291,12 +291,12 @@ function wp_print_media_templates() {
<option value="custom"> <option value="custom">
<?php esc_attr_e('Custom URL'); ?> <?php esc_attr_e('Custom URL'); ?>
</option> </option>
<option value="post" selected> <option value="file" selected>
<?php esc_attr_e('Attachment Page'); ?>
</option>
<option value="file">
<?php esc_attr_e('Media File'); ?> <?php esc_attr_e('Media File'); ?>
</option> </option>
<option value="post">
<?php esc_attr_e('Attachment Page'); ?>
</option>
<option value="none"> <option value="none">
<?php esc_attr_e('None'); ?> <?php esc_attr_e('None'); ?>
</option> </option>
@ -347,12 +347,12 @@ function wp_print_media_templates() {
data-user-setting="urlbutton" data-user-setting="urlbutton"
<# } #>> <# } #>>
<option value="post" selected> <option value="file" selected>
<?php esc_attr_e('Attachment Page'); ?>
</option>
<option value="file">
<?php esc_attr_e('Media File'); ?> <?php esc_attr_e('Media File'); ?>
</option> </option>
<option value="post">
<?php esc_attr_e('Attachment Page'); ?>
</option>
</select> </select>
</label> </label>

View File

@ -1454,6 +1454,12 @@ function wp_enqueue_media( $args = array() ) {
$tabs = apply_filters( 'media_upload_tabs', $tabs ); $tabs = apply_filters( 'media_upload_tabs', $tabs );
unset( $tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library'] ); 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( $settings = 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') ),
@ -1465,6 +1471,7 @@ function wp_enqueue_media( $args = array() ) {
'post' => array( 'post' => array(
'id' => 0, 'id' => 0,
), ),
'defaultProps' => $props,
); );
$post = null; $post = null;