• Hi

    I’m having some problems with admin-ajax. Each time I type a character in media library search, during post creation, wordpress runs admin-ajax.php to search images.

    Problem is my admin-ajax is kind heavy and it takes more than normal to finish loading and returning results. So if it runs every time I type, in a long word search you guys can know what is happens… I have 8, 10, 12 instances of admin-ajax.php loading together.

    I’m still looking into this, but I’m thinking about removing this funcionality which searches for images every time I type something. Instead of this, I want to search images hitting Enter key.

    Is this possible? How can I make it work?

    Thanks!
    Renan

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter renanno

    (@renanno)

    I think this topic would fit better the Hacks subforum.

    Anyway, anyone knows how to do this?

    Thanks

    Thread Starter renanno

    (@renanno)

    Alright, did it.

    If anyone need this, I changed line 7082 in wp-includes/js/media-views.js (don’t forget .min)

    search: function( event ) {
    			if ( event.target.value ) {
    				this.model.set( 'search', event.target.value );
    			} else {
    				this.model.unset('search');
    			}
    	}

    With this:

    search: function( event ) {
    		if ( event.which === 13 ) {
    			if ( event.target.value ) {
    				this.model.set( 'search', event.target.value );
    			} else {
    				this.model.unset('search');
    			}
    		}
    	}
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘admin-ajax and media search’ is closed to new replies.