calvinh99 / mangastyle

The place to find the latest trending mangastyle art on twitter.
0 stars 0 forks source link

Dynamically resize image cards based on aspect ratio #12

Closed calvinh99 closed 2 years ago

calvinh99 commented 2 years ago

If the image is vertically longer, limit it to a 3:4 width to height.

If the image is horizontally longer, limit it to 4:2 width to height.

Anything in between remains as is.

We want to do this while maintaining the image's aspect ratio, so that excess parts outside of 3:4 or 4:2 ratio get center cropped. To do this we must set a div's background image and resize the div. Then set an image element with opacity 0 on top.

Needs javascript.