I want Ghost to generate a set of responsive images automatically. The problem is that it doesn’t generate folder for “s” size (300px). As a result on mobile views browser supplies image with a resolution of 600px. Also, from 1000px to 1600px viewport size browser serves xl (2000px) which is too large.
These are folders I have: w100, w1000, w2000, w600. As you can see w300 is missing. Here is package.json
config:
},
"browserslist": [
"defaults"
],
"config": {
"posts_per_page": 25,
"image_sizes": {
"xxs": {
"width": 30
},
"xs": {
"width": 100
},
"s": {
"width": 300
},
"m": {
"width": 600
},
"l": {
"width": 1000
},
"xl": {
"width": 2000
}
},
"card_assets": true
},
"renovate": {
"extends": [
"@tryghost:theme"
]
}
}
Here is what I have in post-card.hbs
:
<picture>
<source
srcset="{{img_url feature_image size="s" format="webp"}} 300w,
{{img_url feature_image size="m" format="webp"}} 600w,
{{img_url feature_image size="l" format="webp"}} 1000w,
{{img_url feature_image size="xl" format="webp"}} 2000w"
sizes="(max-width: 600px) 300px,
(max-width: 1000px) 600px,
(max-width: 1600px) 1000px,
2000px"
type="image/webp"
/>
<img class="post-card-image"
srcset="{{img_url feature_image size="s"}} 300w,
{{img_url feature_image size="m"}} 600w,
{{img_url feature_image size="l"}} 1000w,
{{img_url feature_image size="xl"}} 2000w"
sizes="(max-width: 600px) 300px,
(max-width: 1000px) 600px,
(max-width: 1600px) 1000px,
2000px"
src="{{img_url feature_image size="m"}}"
alt="{{#if feature_image_alt}}{{feature_image_alt}}{{else}}{{title}}{{/if}}"
/>
</picture>
Probably the last code snippet is irrelevant, because the folder is not generated anyway. I suppose it is an issue with the image generation process in the content management system or with the configuration settings.
Do you know how to fix it?
I’m using Casper theme so maybe someone can check if they have all the folders generated? handle-image-sizes.js
seems to be responsible for that, but the code is too complicated for me to debug.
Thank you in advance!