Media Uploader Default View (3 posts)

  1. borantula
    Posted 2 years ago #


    (I opened this topic in plugins & hack section by mistake a few days ago, so if you are viewing it for second time, sorry, my bad)

    there was one topic that is discussed in now closed thread is default attachments view of new media uploader. People (including me) say that default view for attachments should be uploaded this post instead of all. I looked on this forum and googled it but couldn't find a solution. Then decided to dig in the core.

    I dug into the wp-includes/js/media-view.js file. I don't know about backbone so after a while I became stuck. Below there is a messy code it tried(I copied the method and changed the value). Hope it will be a good starting point. All I want to do is set the default value of attachment-filters to 'uploaded' and update the view below (I think its attachments-browser) according to this.

    Can someone with backbone knowledge can help, so we can make it into a plugin or snippet.

    add_action( 'admin_footer-post-new.php', 'by_media_default' );
    add_action( 'admin_footer-post.php', 'by_media_default' );
    function by_media_default()
    <script type="text/javascript">
    	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 );
    <?php }
  2. SZ4H
    Posted 2 years ago #

  3. borantula
    Posted 2 years ago #

    I've seen this answer, it works as a dom manipulation trick, but not really a fundamental fix I've been looking for. But when necessary can be used till there's a core solution for this.

Topic Closed

This topic has been closed to new replies.

About this Topic