Ghost automatically compresses and resizes images added to your post content and generates automatic responsive assets for maximum performance. For all other images, such as feature images and theme images, the responsive images feature builds responsive image srcsets into your theme, and displays scaled down images when required to improve your site’s overall performance.
Responsive images configuration
Responsive images can be defined in thepackage.json
file. Ghost automatically generates copies of images at the specified sizes, and works like a cache, so the image sizes can be changed at any time. It’s recommended to have no more than 10 image sizes so media storage doesn’t grow out of control.
Here’s a sample of the image sizes in Ghost’s default Casper theme.
Using image sizes
Once image sizes are defined, pass asize
parameter to the {{img_url}} helper in your theme to output an image at a particular size.
Converting images to smaller image types
Pass aformat
parameter to the {{img_url}} helper in your theme to output an image in a particular image format. This only works in combination with the size
parameter.
.jpg
extension.
WebP is supported by all modern browsers, but we recommend to always add a fallback to the original file type to achieve wider browser support. Use a <picture>
tag for this, which allows the browser to choose the first format it supports: