# How are srcsets generated/Where are the settings?

**URL:** <https://forum.getkirby.com/t/how-are-srcsets-generated-where-are-the-settings/17503>\
**Category:** Questions\
**Tags:** v3\
**Created:** [March 3, 2020, 11:47pm UTC](https://forum.getkirby.com/t/how-are-srcsets-generated-where-are-the-settings/17503 "2020-03-03T23:47:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seriamlo](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@seriamlo](https://forum.getkirby.com/u/seriamlo)\
**Post date:** [March 3, 2020, 11:47pm UTC](https://forum.getkirby.com/t/how-are-srcsets-generated-where-are-the-settings/17503/1 "2020-03-03T23:47:03Z")

</div>

I see that without any plugin after uploading an image to a page, that within the REST API I get a srcset for this image:

```
"srcset": "http:\/\/cms.cda.test\/media\/pages\/home\/2744598729-1583104264\/img-4166rrr-352x.jpg 352w, http:\/\/cms.cda.test\/media\/pages\/home\/2744598729-1583104264\/img-4166rrr-864x.jpg 864w, http:\/\/cms.cda.test\/media\/pages\/home\/2744598729-1583104264\/img-4166rrr-1408x.jpg 1408w"

```

I asked myself where are the settings for these sizes saved and how can I edit them?  
352px, 864px and 1408px…

I search the repo on github and found this:

> <https://github.com/getkirby/kirby/blob/785e941e41dfbfaa4fe8d43a7c130302bde4539a/src/Cms/ModelWithContent.php#L350>

This tells me that whenever I have a card layout for my images that I get these three sizes saved.  
That also makes sense why I don’t have these sizes for all of my images.

What I now need is the generation of custom sizes on upload, because I can’t use src-set kirbytags in my headless setup. So how can I trigger resizing on upload and afterwards having access to these files via REST API?

It would be crucial for me to have control over image sizes.

Thank you in advance.  
cheers

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [March 4, 2020, 8:43am UTC](https://forum.getkirby.com/t/how-are-srcsets-generated-where-are-the-settings/17503/2 "2020-03-04T08:43:30Z")

</div>

srcset presets are defined here:

> **[$file-\>srcset()](https://getkirby.com/docs/reference/objects/cms/file/srcset)**
>
> Create a srcset definition for the given sizes Sizes can be defined as a simple array. They can also be set up in the config with the thumbs.srcsets option.

somethink like this will only work on upload

> [@Generating thumbs on upload](https://forum.getkirby.com/t/generating-thumbs-on-upload/12514):
>
> Is it possible to set up Kirby 3 in a way that it generates thumbs in predefined sizes on upload right away?

there are scripts in the forum how to apply that to all `site.index.images()` if you need to recreate thumbs for uploaded images.

also consider this plugin for kirby as headless

> **[GitHub - robinscholz/better-rest: Kirby plugin for better REST requests](https://github.com/robinscholz/better-rest)**
>
> Kirby plugin for better REST requests. Contribute to robinscholz/better-rest development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![seriamlo](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@seriamlo](https://forum.getkirby.com/u/seriamlo)\
**Post date:** [March 4, 2020, 12:26pm UTC](https://forum.getkirby.com/t/how-are-srcsets-generated-where-are-the-settings/17503/3 "2020-03-04T12:26:27Z")

</div>

Thank you for your help.

I think that is indeed what I need. The resizing on upload.

I already have better-rest in use, but I don’t see no effect.  
But I did search a bit in the source code of better-rest and realized that he just creates new endpoints where `->resize()` is used. So I am currently building my own endpoint with custom resizes, which should work as well.

Anyway the creation on upload is supercool.  
I will see if it works for me.  
Thank you.

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [March 4, 2020, 4:49pm UTC](https://forum.getkirby.com/t/how-are-srcsets-generated-where-are-the-settings/17503/4 "2020-03-04T16:49:28Z")

</div>

betterest will not create the thumbs. i just mentioned it since i consider it helpful for headless. but glad that you already use it.
