Sort by image resolution in gallery

前端 未结 5 906
-上瘾入骨i
-上瘾入骨i 2020-12-01 17:11

I made this gallery a while ago: https://jsfiddle.net/5e9L09Ly/

Don\'t worry it won\'t upload anything.

I made that you can sort by file size, but I want to

5条回答
  •  青春惊慌失措
    2020-12-01 17:50

    you can get the image size using this an after you sort as per your requirement

    this is my example : how to get image size before load https://jsfiddle.net/mmghori/Lsnc0sr7/

    and

    here is you updated fiddle https://jsfiddle.net/mmghori/ubgLv3cb/ , in this fiddle i add my code and console image size,

    so i just find how to get image size before load.

    
    
    

    var _URL = window.URL || window.webkitURL; $("#file").change(function(e) { var file, img; if ((file = this.files[0])) { img = new Image(); img.onload = function() { $("#fileSize").text(this.width + "x" + this.height); }; img.onerror = function() { alert( "not a valid file: " + file.type); }; img.src = _URL.createObjectURL(file); } });

提交回复
热议问题