# Custom responsive image sizes in galleries

**URL:** <https://forum.ghost.org/t/custom-responsive-image-sizes-in-galleries/26852>\
**Category:** Themes\
**Created:** [November 16, 2021, 7:27pm UTC](https://forum.ghost.org/t/custom-responsive-image-sizes-in-galleries/26852 "2021-11-16T19:27:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Agrarvolution](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/agrarvolution/32/12100_2.png) [@Agrarvolution](https://forum.ghost.org/u/Agrarvolution)\
**Post date:** [November 16, 2021, 7:27pm UTC](https://forum.ghost.org/t/custom-responsive-image-sizes-in-galleries/26852/1 "2021-11-16T19:27:12Z")

</div>

Hey,  
I’m currently looking into improving my website speed and noticed that I can’t change the sizes that are automatically generated for the srcset of gallery images. Especially on small mobile devices you waste a lot of bandwidth with the default values, that are used depending on your theme.

I looked into the code further and saw that this was hardbaked in gallery.js (node\_modules/@tryghost/kg-default-cards/lib/cards/gallery.js)

```auto
if (img.getAttribute('srcset') && image.width >= 720) {
	if (rows.length === 1 && row.length === 1 && image.width >= 1200) {
		img.setAttribute('sizes', '(min-width: 1200px) 1200px');
	} else {
		img.setAttribute('sizes', '(min-width: 720px) 720px');
	}
}

```

Why is there no option for theme designers to at least give an option to set those values in package.json, like with image\_sizes?  
Or am I overlooking something?

I’m tempted to edit the file to my needs, but I want to keep the easy of updating ghost, when you haven’t meddled with the source code. :/

I’m looking forward to your input. 😁

---

<div class="post-metadata">

**Author:** ![Agrarvolution](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/agrarvolution/32/12100_2.png) [@Agrarvolution](https://forum.ghost.org/u/Agrarvolution)\
**Post date:** [November 25, 2021, 10:45pm UTC](https://forum.ghost.org/t/custom-responsive-image-sizes-in-galleries/26852/2 "2021-11-25T22:45:30Z")

</div>

So here is an update from my side. For everybody hitting the same issue:

I thought about making my own integration, but documentation is a bit sparce and seemed overkill.  
So my solution was to create myself a small generator script that creates a figure card’s html with “modifications”.

 ![2021-11-25 23.42.44 localhost 5a5694bbeec1_K](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/0/08ba2a94170801ededec41beb166fc8266a82c01.jpeg)

It generates html that can be inserted html in the editor. I tried live parsing on the website, which worked well, but I’m not sure how future proof that is, so inserting HTML seemed the best, but undeniably - clunky.

I saw other people either writing a separate front-end in Vue. Which seemed way too much of an overkill for my case.

Ghost is really great, but it just lacks that final bit of customization.

If there is interest for the script I can post it here. 🤷🏻‍♂️
