As staticImageUrlPrefix: 'content/images'
It took me a long time to find that.
Now I have a Google Load Balancer with a content/images/* prefix directed to the bucket from the domain to force Ghost to prove srcsets correctly (it is specifically coded to only provide them for “internal” images).
That’s the goal. When using the Google Storage Adapter to take advantage of a GCP Bucket Ghost will never even see the image requests (as intended) - but it looks like it generates the resized images only on request. The adapter has to generate them. Then you have to trick Ghost into producing srcsets for the image tags because it’s logic locked to not produce them for external hosts.
The first work-around is the load balancer work-around mentioned. A google load balancer remaps content/images/* -> bucket. This tricks Ghost into providing the srcsets correctly in the frontend helpers because it thinks https://MYSITE/content/images/* is being served by Ghost (but it isn’t).
An assetPath config item was added to the ghost-google-cloud-storage-new adapter to make it easier to tweak the path.
This is the fork of the ghost-google-cloud-storage-new adapter I’m working in
Maybe a toggle for the srcset helpers in the templates to force them on? Once forced on, maybe the Ghost admin upload could get the sizes from the theme and use the adapter.save() on its own? I’m not sure what would be best.
Small side note: I am not the greatest node developer…
Uploaded images go through the Ghost image processor/Sharp and are sent to the bucket with all of the sizes specified in the package.json of the current theme. All images are served directly from the bucket. Images appear in the theme with the appropriate srcsets.
I have this really nasty chunk of synchronous code to sort out later: