Keep the original ratio in a thumbnail image

CSS Reference: background-size can stretch a background image proportionally using cover or contain. Check out this Demo. HTML <div class=”square”></div> <div class=”rec”></div> CSS .rec, .square { border: solid red 1px; background-color:black; background: url(“https://placeholdit.imgix.net/~text?txtsize=23&txt=120×120&w=120&h=120”); background-size:contain; background-repeat: no-repeat; background-position: center; } .rec { width:100px; height:60px; } .square { width:100px; height:100px; } The remaining space with contain will … Read more

How to modify images during upload

You need to use attachment_fields_to_save filter. There is nice example on codex. So instead of copying that here, I would rather like to point you towards the codex page. Please take a look here. I hope this helps.

How to use lossless compression with WP_Image_Editor

With @jgraup ‘s help in comments, I had a look at the responsive images plugin linked there. While that particular one has several other filters on things like post content which I would have preferred not to use, the RespImg class included is exactly what I was wanting. I was originally considering what would be … Read more