decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

Save image in different formats in the media library

Open alberto56 opened this issue 5 years ago • 6 comments

Is your feature request related to a problem? Please describe.

I am looking to have any number of image transformations in my git repo directly without having an account on a third-party system.

Describe the solution you'd like

In my admin/config.yml file it says:

media_folder: 'assets/uploads'

In the admin backend of my, when uploading, say, a 5Mb image called kittens.jpg to my media library, it goes to ./assets/uploads/kittens.jpg, then I can select it when adding it to a post.

Would it be possible to save the image in several sizes?

Describe alternatives you've considered

Could we have something like this in admin/config.yml?

media_folder: 'assets/uploads'
image_transformations:
  - name: small
     format: jpg
     quality: 60
     width: 100
  - name: medium
     width: 400
     default: true

Then when I upload a 5 Mb "kittens" image, it would automatically create these files:

  • ./assets/uploads/kittens.jpg
  • ./assets/uploads/_transformations/small/kittens.jpg
  • ./assets/uploads/_transformations/medium/kittens.jpg

And, then in my "embed image" widget, there could be an additional field "transformation" which would default to "medium", and that file would then be embedded into my post.

Additional context

Alhough Cloudinary and other services can be very useful, for very small projects these might be overkill. My experience with front-end content editors is that often they don't have an appreciation of the importance of keeping image size to a minimum, so automating that in part might be interesting.

alberto56 avatar Oct 26 '19 23:10 alberto56

Netlify CMS runs in the browser, so it can't handle that kind of process itself. What you can do is have your SSG take care of the image transformations for you when the site is being built.

If you're using Neltify you can of course take advantage of Netlify Large Media

tomrutgers avatar Oct 28 '19 17:10 tomrutgers

Thanks! I appreciate the clarification; I will close this issue then.

alberto56 avatar Oct 28 '19 18:10 alberto56

We actually can do quite a bit of image processing in the browser, and resizing is pretty simple. I thought we had another issue for this but I'm not seeing one. Going to reopen as this should eventually be possible.

erquhart avatar Nov 07 '19 19:11 erquhart

Has anyone worked on this? I may take a stab -- having browser-based resizing and compression built-in could be cool for those who solely using Netlify CMS and git-backed storage.

mariolopjr avatar Jan 15 '20 10:01 mariolopjr

Go for it @mariolopjr we would love the contribution

erezrokah avatar Jan 15 '20 11:01 erezrokah

Hi, is there any interest in landing this feature in the future. It would really make my workflow easier, as the way things are now forces me to resize images externally before uploading. This is fine as long as I am the only one using the interface, but it becomes a big problem when others have access and start uploading 4k images to the page.

It would really be great to resize images on upload.

jzbor avatar Sep 27 '23 16:09 jzbor