Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Automated Image Scaling with Client Hints #105

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gshel
Copy link
Contributor

@gshel gshel commented Dec 5, 2023

Description

The following changes allow users to follow the suggestions outlined in How to Scale an Image Automatically using Client Hints, specifically:

  1. Scaling an image's width automatically (e.g. 100vw returns an image that is the same width as the viewport)
  2. Avoiding cache misses through advanced usage, which allows users to determine the "jumps" between image resource sizes

Changes made:

  1. Accept string or number Inputs for maxSize.height and maxSize.width via netlify.toml
  2. Accept string Inputs for maxSize.crop via netlify.toml

Issue Ticket Number

Fixes #104

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I have followed the contributing guidelines of this project as mentioned in CONTRIBUTING.md
  • I have created an issue ticket for this PR
  • I have checked to ensure there aren't other open Pull Requests for the same update/change?
  • I have performed a self-review of my own code
  • I have run tests locally to ensure they all pass
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes needed to the documentation

…ize.width so users can follow the instructions in https://cloudinary.com/blog/automatic_responsive_images_with_client_hints

* Add Inputs maxSize.crop so users can specify a cloudinary crop mode for their images
Copy link

netlify bot commented Dec 5, 2023

Deploy Preview for netlify-plugin-cloudinary ready!

Name Link
🔨 Latest commit f8239ae
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-cloudinary/deploys/656f89a5d3b8cb000833b8ad
😎 Deploy Preview https://deploy-preview-105--netlify-plugin-cloudinary.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

* Include hyperlinks for new people
@gshel
Copy link
Contributor Author

gshel commented Dec 5, 2023

Happy to split the unrelated documentation updates into a separate PR if it would make things easier 🎉

@colbyfayock
Copy link
Collaborator

thanks @gshel changes look good

im curious to hear about your use case with the crop mode. the reason i hadnt originally allowed that to be configurable was the thought that blanket cropping images across the site would present a challenge for the variety ways an image could be presented, where i was going to eventually allow someone to pass in parameters, such as a URL query params perhaps, to do that programmatically

as far as client hints - what do you think about added the option to allow people to inject the Client Hints meta tag to their site?

perhaps if they pass in an option such as:

clientHints: ["Dpr", "Viewport-Width", "Width"]

we would add the tags:

  <meta http-equiv="accept-ch" content="Dpr, Viewport-Width, Width">
  <meta http-equiv="delegate-ch" content="sec-ch-width https://res.cloudinary.com; sec-ch-dpr https://res.cloudinary.com; sec-ch-viewport-width https://res.cloudinary.com;">

based on those values

thoughts?

@colbyfayock
Copy link
Collaborator

oh, can you also update the documentation website table of configuration options? my intent is to eventually remove them from the README and instead only have them on the documentation site to avoid separate maintenance

https://github.com/cloudinary-community/netlify-plugin-cloudinary/blob/main/docs/src/pages/configuration.mdx

it should more or less be the same code that you have already updated, just need to copy and paste i believe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add support for automatic image scaling with client hints
2 participants