Sort by image resolution in gallery

前端 未结 5 905
-上瘾入骨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 18:01

    The gallery itself is pretty basic, it asks for a directory and it will then display all the images and videos in that directory.

    Here is simple solution, how to get size of all images on webpage, so if you have something like simple photo-gallery, what getting images from folder and you haven't got any list of this images, this is the simplest solution how to get size of that and then you can process in how you want.

    for( i=0; i < document.images.length; i++)
    { 
      width = document.images[i].width;
      height = document.images[i].height;
      console.log("Image number: " + i + " Size: " + width + "x" + height);
    }
    
    
    
    Get image size example
    
    
    
    
    
    

提交回复
热议问题