Skip to content

Commit 07e876b

Browse files
committed
make aspectRatio check more readable
1 parent d2982ff commit 07e876b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

feature-meme.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ request(`https://picsum.photos/v2/list?page=${pages}&limit=100`, function(
77
const random = Math.floor(Math.random() * 100);
88
imageObj=response[random];
99
image.src = imageObj.download_url;
10+
let aspectRatio= imageObj.width/imageObj.height;
1011
//dont load really wide images and portrait images
11-
while(imageObj.height/imageObj.width>0.7|| imageObj.width/imageObj.height > 1.8)
12+
while(aspectRatio<(4/3)|| aspectRatio>(16/9))
1213
{
14+
console.log('image rejected, reloading');
1315
imageObj=response[Math.floor(Math.random() * 100)];
1416
image.src = imageObj.download_url;
17+
aspectRatio= imageObj.width/imageObj.height;
1518
}
1619
image.addEventListener("load", () => {
1720
request("https://corporatebs-generator.sameerkumar.website/", function(

0 commit comments

Comments
 (0)