• Hi!

    I’ve overridden wp.media.view.AttachmentFilters (from media-view.js) with the following code so the default selected option in the media uploader dropdown is “Uploaded to this post” instead of “All”, but still shows ALL the attachments:

    <?php
        add_action( 'admin_footer-post-new.php', 'my_default_view' );
        add_action( 'admin_footer-post.php', 'my_default_view' );
    
        function my_default_view()
        {
            ?>
        <script type="text/javascript">
        jQuery(document).ready(function($){
    
        	wp.media.view.AttachmentFilters.prototype.select =  function() {
        		var model = this.model,
        			value = 'uploaded',
        			props = model.toJSON();
    
        		_.find( this.filters, function( filter, id ) {
        			var equal = _.all( filter.props, function( prop, key ) {
        				return prop === ( _.isUndefined( props[ key ] ) ? null : props[ key ] );
        			});
    
        			if ( equal )
        				return value = id;
        		});
    
        		this.$el.val( value );
        	}
    
        });
        </script>
        <?php }

    Any ideas what I’m doing wrong? Thanks

  • The topic ‘Set "Uploaded to this post" as default view in the media uploader’ is closed to new replies.