查看jQuery file upload的image preview如何工作的

查看readme中的说明,

注释掉这个js的引用

<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<!--<script src="//blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js"></script>-->

然后发现错误在loadImage.parseMetaData,提示loadImage undefined

复制代码
loadImageMetaData: function (data, options) {
                if (options.disabled) {
                    return data;
                }
                var that = this,
                    dfd = $.Deferred();
                loadImage.parseMetaData(data.files[data.index], function (result) {
                    $.extend(data, result);
                    dfd.resolveWith(that, [data]);
                }, options);
                return dfd.promise();
            },
复制代码

 在loadImageMetaData函数前面,加上console.trace(); 刷新页面,再次尝试,然后查看stack trace,但是这个结果没有意义。可读性太差了。

 

使用stacktrace.js查看堆栈信息

 引用https://cdnjs.cloudflare.com/ajax/libs/stacktrace.js/2.0.0/stacktrace.js,然后在loadImageMetaData函数处,输出堆栈信息

复制代码
 var callback = function(stackframes) {
                    var stringifiedStack = stackframes.map(function(sf) {
                        return sf.toString();
                    }).join('\n');
                    console.log(stringifiedStack);
                };

                var errback = function(err) { console.log(err.message); };

                StackTrace.get().then(callback).catch(errback);
复制代码

 


loadImageMetaData()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-image.js:289:28

func()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:84:65

复制代码
_processFile: function (data, originalData) {
            var that = this,
                dfd = $.Deferred().resolveWith(that, [data]),
                chain = dfd.promise();
            this._trigger('process', null, data);
            $.each(data.processQueue, function (i, settings) {
                var func = function (data) {
                    if (originalData.errorThrown) {
                        return $.Deferred()
                                .rejectWith(that, [originalData]).promise();
                    }
                    return that.processActions[settings.action].call(
                        that,
                        data,
                        settings
                    );
                };
                chain = chain.then(func, settings.always && func);
            });
            chain
                .done(function () {
                    that._trigger('processdone', null, data);
                    that._trigger('processalways', null, data);
                })
                .fail(function () {
                    that._trigger('processfail', null, data);
                    that._trigger('processalways', null, data);
                });
            return chain;
        },
复制代码

function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3305:32

apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3148:29

add()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3194:6

function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3304:28

callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22

jQuery.each()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3301:13

promise.promise()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3361:8

jQuery.Deferred(function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3300:19

_processFile/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:90:31

   chain = chain.then(func, settings.always && func);

callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22

_processFile()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:78:15

$.each(data.processQueue, function (i, settings) {

 

$.widget/</proxiedPrototype[prop]</<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:127:25

returnValue = value.apply( this, arguments );

func()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:153:41

  return that._processFile(opts, data);

 

function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3305:32

apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3148:29

add()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3194:6

function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3304:28

callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22

jQuery.each()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3301:13

promise.promise()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3361:8

jQuery.Deferred(function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3300:19

process/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:157:67

that._processingQueue = that._processingQueue.then(func, func)

 

callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22

process()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:146:19

$.each(data.files, function (index) {

 

$.widget/</proxiedPrototype[prop]</<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:127:25

returnValue = value.apply( this, arguments );

 

$.widget.bridge/$.fn[name]/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:220:39

methodValue = instance[ options ].apply( instance, args );

callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22

each()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:136:16

$.widget.bridge/$.fn[name]()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:206:9

this.each(function() {

 

add/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-ui.js:115:34

 return $this.fileupload('process', data);

 

function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3305:32

apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3148:29

add()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3194:6

function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3304:28

callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22

jQuery.each()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3301:13

promise.promise()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3361:8

jQuery.Deferred(function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3300:19

_addConvenienceMethods/data.process()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:663:27

 ).then(resolveFunc, rejectFunc);

 

add()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-ui.js:114:22

data.process(function () {

_trigger()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:527:13

callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
event.isDefaultPrevented() );

_onAdd/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:1037:31

result = that._trigger(
'add',
$.Event('add', {delegatedEvent: e}),
newData
);

 

callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22

_onAdd()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:1030:15

$.each(fileSet || files, function (index, element) {

 

$.widget/</proxiedPrototype[prop]</<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:127:25

returnValue = value.apply( this, arguments );

 

_onChange/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:1236:26

that._onAdd(e, data);

 

apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3148:29

add()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3194:6

always()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3295:14

_onChange()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:1226:53

this._getFileInputFiles(data.fileInput).always(function (files) {

 

$.widget/</proxiedPrototype[prop]</<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:127:25

handlerProxy()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:438:7

return ( typeof handler === "string" ? instance[ handler ] : handler )
.apply( instance, arguments );

 

event.namespace_re.test()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:4670:8

handle()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:4338:27

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(422)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2017-06-26 ISheet ICell
2014-06-26 委托的begininvoke
2014-06-26 C# 给某个方法设定执行超时时间
2014-06-26 C#中的Invoke----control上的以及delegate的是不一样的
点击右上角即可分享
微信分享提示