Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Media: Restore 3.4 behavior by consulting the old-school DB options f…
…or 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.

Merges [23262] to the 3.5 branch.
fixes #22841.



git-svn-id: https://develop.svn.wordpress.org/branches/3.5@23273 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
nacin committed Jan 4, 2013
1 parent 3b7c0c1 commit bad4c6b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
9 changes: 5 additions & 4 deletions wp-includes/js/media-editor.js
Expand Up @@ -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 ) {
Expand All @@ -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: []
});
Expand All @@ -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 )
Expand Down
7 changes: 4 additions & 3 deletions wp-includes/js/media-views.js
Expand Up @@ -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' )
};
},

Expand Down
16 changes: 8 additions & 8 deletions wp-includes/media-template.php
Expand Up @@ -291,12 +291,12 @@ function wp_print_media_templates() {
<option value="custom">
<?php esc_attr_e('Custom URL'); ?>
</option>
<option value="post" selected>
<?php esc_attr_e('Attachment Page'); ?>
</option>
<option value="file">
<option value="file" selected>
<?php esc_attr_e('Media File'); ?>
</option>
<option value="post">
<?php esc_attr_e('Attachment Page'); ?>
</option>
<option value="none">
<?php esc_attr_e('None'); ?>
</option>
Expand Down Expand Up @@ -347,12 +347,12 @@ function wp_print_media_templates() {
data-user-setting="urlbutton"
<# } #>>

<option value="post" selected>
<?php esc_attr_e('Attachment Page'); ?>
</option>
<option value="file">
<option value="file" selected>
<?php esc_attr_e('Media File'); ?>
</option>
<option value="post">
<?php esc_attr_e('Attachment Page'); ?>
</option>
</select>
</label>

Expand Down
7 changes: 7 additions & 0 deletions wp-includes/media.php
Expand Up @@ -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') ),
Expand All @@ -1465,6 +1471,7 @@ function wp_enqueue_media( $args = array() ) {
'post' => array(
'id' => 0,
),
'defaultProps' => $props,
);

$post = null;
Expand Down

0 comments on commit bad4c6b

Please sign in to comment.