Unsplash support for img_url size

#1

I’ve got a Ghost blog that uses the built-in Unsplash image selector. The problem is that it is terribly inefficient since it always loads pics at least 1080px wide (even for small thumbnails). I’d like to fix that in one of two ways:

  1. Update the img_url handlebar helper to add dedicated support for Unsplash images (replace/add query string for responsive size (w=1080, h=480, etc.)
  2. Add a custom handlebar helper to correctly size and attribute unsplash images. This is preferred but I don’t know if there is a standard way to add new handlebar helpers (that includes JS, not just template partials).

Please let me know if there have been decisions and/or discussions already made around this. I am more than happy to implement this myself, I just want to make sure it “fits in” correctly.

Thanks in advanced!

- Jim

#2

That’s a great idea, Jim! We already have image_sizes in package.json. It would be great if {{img_url feature_image size="s"}} generated an Unsplash image URL with w=480 parameter for example.

#3

Exactly! It would be easy to use if it’s built into the img_url helper, but I also understand that architecturally it might be better to split it out. I’m happy to start a pull request for it, I just want some guidance from a Ghost dev before starting down a path.