t5-libraries
t5-libraries copied to clipboard
Media upload doesn’t work with AJAX editor
When media uploads are enabled in the AJAX Editor, the upload button is visible, but clicking it raises just an error:
Uncaught exception: TypeError: Cannot convert 'n' to object
Error thrown at line 595, column 2 in <anonymous function: w.template>(n, t, r):
n.replace(u, function(t, r, e, u, o) {
called from line 27, column 3 in <anonymous function>(data):
compiled = compiled || _.template( $( '#tmpl-' + id ).html(), , options );
called from line 2939, column 3 in <anonymous function: css>():
media.view.Attachments.$head().append( this.cssTemplate({
called as bound function from line 2924, column 3 in <anonymous function: initialize>():
this.css();
called via Function.prototype.apply() from line 3521, column 3 in <anonymous function: initialize>():
return media.view.Attachments.prototype.initialize.apply( this, arguments );
called via Function.prototype.apply() from line 773, column 3 in <anonymous function: a.View>(t):
this.initialize.apply(this, arguments);
called via Function.prototype.apply() from line 347, column 3 in <anonymous function: constructor>():
Backbone.View.apply( this, arguments );
called via Function.prototype.apply() from line 880, column 3 in <anonymous function: constructor>(options):
wp.Backbone.View.apply( this, arguments );
called via Function.prototype.apply() from line 1121, column 5 in <anonymous function: r>():
return i.apply(this, arguments)
called via Function.prototype.apply() from line 1121, column 5 in <anonymous function: r>():
return i.apply(this, arguments)
To debug that, I have replaced the minified underscore.js
with an unminified version from the original repo (not included in WordPress core for no obvious reasons). The error is now:
Uncaught exception: TypeError: Cannot convert 'text' to object
Error thrown at line 1130, column 4 in <anonymous function: _.template>(text, data, settings):
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
called from line 27, column 3 in <anonymous function>(data):
compiled = compiled || _.template( $( '#tmpl-' + id ).html(), , options );
called from line 2939, column 3 in <anonymous function: css>():
media.view.Attachments.$head().append( this.cssTemplate({
called as bound function from line 2924, column 3 in <anonymous function: initialize>():
this.css();
called via Function.prototype.apply() from line 3521, column 3 in <anonymous function: initialize>():
return media.view.Attachments.prototype.initialize.apply( this, arguments );
called via Function.prototype.apply() from line 773, column 3 in <anonymous function: a.View>(t):
this.initialize.apply(this, arguments);
called via Function.prototype.apply() from line 347, column 3 in <anonymous function: constructor>():
Backbone.View.apply( this, arguments );
called via Function.prototype.apply() from line 880, column 3 in <anonymous function: constructor>(options):
wp.Backbone.View.apply( this, arguments );
called via Function.prototype.apply() from line 1121, column 5 in <anonymous function: r>():
return i.apply(this, arguments)
called via Function.prototype.apply() from line 1121, column 5 in <anonymous function: r>():
return i.apply(this, arguments)