WordPress/wp-includes/js/wp-util.min.js
joedolson daa1cbbbfe Media: Adapt response shape depending on type of query.
Restore inheriting the backbone fetch in the media library and adapt the AJAX response according to the action performed in the media query.

In [51145], the response shape was restored to the original shape, and a custom fetch was added to handle assigning the totalAttachments information in the collection. The custom fetch triggered a new set of bugs relating to zero-sized collections and loading individual images. 

props adamsilverstein, ryelle, peterwilsoncc, Presskopp, desrosj.
Fixes #53421, #53419.
Built from https://develop.svn.wordpress.org/trunk@51187


git-svn-id: http://core.svn.wordpress.org/trunk@50796 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-20 23:27:01 +00:00

2 lines
1.3 KiB
JavaScript

/*! This file is auto-generated */
window.wp=window.wp||{},function(s){var e="undefined"==typeof _wpUtilSettings?{}:_wpUtilSettings;wp.template=_.memoize(function(t){var a,n={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(e){return(a=a||_.template(s("#tmpl-"+t).html(),n))(e)}}),wp.ajax={settings:e.ajax||{},post:function(e,t){return wp.ajax.send({data:_.isObject(e)?e:_.extend(t||{},{action:e})})},send:function(n,e){var t,a;return _.isObject(n)?e=n:(e=e||{}).data=_.extend(e.data||{},{action:n}),e=_.defaults(e||{},{type:"POST",url:wp.ajax.settings.url,context:this}),(t=(a=s.Deferred(function(a){e.success&&a.done(e.success),e.error&&a.fail(e.error),delete e.success,delete e.error,a.jqXHR=s.ajax(e).done(function(e){var t;"1"!==e&&1!==e||(e={success:!0}),_.isObject(e)&&!_.isUndefined(e.success)?(t=this,a.done(function(){"query-attachments"===n.data.action&&a.jqXHR.hasOwnProperty("getResponseHeader")&&a.jqXHR.getResponseHeader("X-WP-Total")?t.totalAttachments=parseInt(a.jqXHR.getResponseHeader("X-WP-Total"),10):t.totalAttachments=0}),a[e.success?"resolveWith":"rejectWith"](this,[e.data])):a.rejectWith(this,[e])}).fail(function(){a.rejectWith(this,arguments)})})).promise()).abort=function(){return a.jqXHR.abort(),this},t}}}(jQuery);