# New image resizing mode \`shrink\_fit\`

**URL:** https://zola.discourse.group/t/new-image-resizing-mode-shrink-fit/203
**Category:** Feature requests
**Created:** [September 19, 2019, 9:48pm UTC](https://zola.discourse.group/t/new-image-resizing-mode-shrink-fit/203 "2019-09-19T21:48:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Nukesor](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@Nukesor](https://zola.discourse.group/u/Nukesor)
#### Post date: [September 19, 2019, 9:48pm UTC](https://zola.discourse.group/t/new-image-resizing-mode-shrink-fit/203/1 "2019-09-19T21:48:19Z")

</div>

Hi!

I recently started using zola and found myself using shortcodes for automatic image downscaling.  
After trying around a little bit, I found that using any `fit` mode always resizes the image to the exact specified size of the respective dimension.  
Since I only want to optimize my website for mobile usage, the upscaling of images was rather troubling than helpful, since the quality of automatically upscaled image was naturally poorer and looked really bad.

Because of this I thought that a new mode might be useful (`shrink_fit`), which only resizes and fits to the specified dimensions, if the image is bigger than the specified sizes in any dimension.

I already applied the changes in my fork and I’m ready to open a PR, if you like the idea:

> <https://github.com/Nukesor/zola/commit/ea5aa640e490e635187f647d45fbb7c8c8b7b57e>

Otherwise feel free to criticize the idea or to suggest changes.

Best regards,  
Arne

---

<div class="post-metadata">

### Author: ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)
#### Post date: [September 20, 2019, 8:33am UTC](https://zola.discourse.group/t/new-image-resizing-mode-shrink-fit/203/2 "2019-09-20T08:33:04Z")

</div>

Hello!

That looks like a good addition but I’m wondering if `fit` should do that directly rather than adding a new mode. If an image is already fitting, there shouldn’t be anything done to it with `fit` I think?

---

<div class="post-metadata">

### Author: ![Nukesor](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@Nukesor](https://zola.discourse.group/u/Nukesor)
#### Post date: [September 20, 2019, 11:32am UTC](https://zola.discourse.group/t/new-image-resizing-mode-shrink-fit/203/3 "2019-09-20T11:32:37Z")

</div>

That would most likely be the easiest way to implement this, but it would prevent users to scale images up. I’m not sure if anybody needs the upscaling functionality, but that’s for you to decide 🙂

---

<div class="post-metadata">

### Author: ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)
#### Post date: [September 21, 2019, 10:44am UTC](https://zola.discourse.group/t/new-image-resizing-mode-shrink-fit/203/4 "2019-09-21T10:44:24Z")

</div>

I really don’t think many people actually want upscaling, except maybe for SVGs which aren’t supported (yet). I could be wrong though. Can you open the PR replacing the behaviour of `fit` and I’ll ping the original author to see if he has some thoughts?
