Is there a way to resize an image using only HTML and CSS, maintaining its proportions and applying a crop effect without any server code? I want to specify a width for the image while keeping its proportions intact, but if the height exceeds a certain value, I want to crop it to that specified height.
I'm aware of how to achieve this with server-side code, but I prefer not to go down that route. Using server-side code would require referencing a different file and displaying the image like <img src="picture.php" />
. I'd rather handle the image processing directly on the same page where it's displayed.
The issue I have is that sending the image header means that nothing else on the page will display.
Are there ways to accomplish this purely using HTML and CSS? :P
I've created a function that resizes images (minus the cropping part) which returns width="" height=""
, and I use it like this:
<img src="image.jpg" resize("image.jpg") />
. However, I can't figure out how to implement the cropping aspect...
Thank you!