Undefined (loadImage) is not a Function Error

1,239 views
Skip to first unread message

Ari King

unread,
Oct 16, 2012, 11:42:05 AM10/16/12
to jquery-f...@googlegroups.com
Hi,

When I configure jquery-file-upload to display a preview image I get:

Uncaught TypeError: undefined is not a function
jquery.fileupload-fp.js:87

Does anyone know what is the cause of this error and how to solve it? Thanks.

-Ari

Peter Oríšek

unread,
Apr 22, 2014, 7:17:44 AM4/22/14
to jquery-f...@googlegroups.com
Hi,
I'd had similar problem and solve it like this:

loadImage: function (data, options) {
//                console.log(data);
//                console.log(options);
                if (options.disabled) {
                    return data;
                }
                var that = this,
                    file = data.files[data.index],
                    dfd = $.Deferred(); 
                var reg = new RegExp(options.fileTypes);

                if (($.type(options.maxFileSize) === 'number' &&
                            file.size > options.maxFileSize) ||
                        (options.fileTypes &&
                            !/*options.fileTypes.test(file.type)*/reg.test(file.type)) ||
                        !loadImage(
                            file,
                            function (img) {
                                if (img.src) {
                                    data.img = img;
                                }
                                dfd.resolveWith(that, [data]);
                            },
                            options
                        )) {
                    return data;
                }
                return dfd.promise();
            },
Reply all
Reply to author
Forward
0 new messages