This isn’t strictly true, Ghost has a separate service for resizing images that is accessed by specifying the image size in the URL (limited to sizes configured in the theme):
The same principle exists for all images uploaded in Ghost, whether it’s feature images or content images. You can build up your own srcset
using those urls in a HTML or markdown card, eg:
<img class="post-image"
srcset="/content/images/size/w300/2019/04/17/image.jpg 300w,
/content/images/size/w600/2019/04/17/image.jpg 600w,
/content/images/size/w1000/2019/04/17/image.jpg 1000w,
/content/images/size/w2000/2019/04/17/image.jpg 2000w"
sizes="(max-width: 1000px) 400px, 700px"
src="/content/images/size/w600/2019/04/17/image.jpg"
alt="{{title}}"
/>
Note the /size/{size}/
part of the URL, that directs the request to the image resizing service which will generate the resized imaged on the fly and store it locally for faster subsequent requests.
The reason srcset
output hasn’t been implemented for content images yet is due to problems with the current design where only images sizes specified in the theme can be generated to avoid opening up DoS attacks. Content is static so if you change theme or adjust the allowed image sizes to cater for a new design then you may end up with image sizes referenced in your content that can no longer be dynamically generated.
We need to come up with an alternative method for specifying generally allowed image sizes, then a plan for how old content could be migrated to use dynamic image sizes (if that’s possible). There also need to be considerations made for how the new feature would work inside markdown cards, again if that’s possible, it may need to be limited to image cards.
It’s something the core team is thinking about but we want to make sure the implementation is correct this time