prismicio / prismic-helpers

Set of helpers to manage Prismic data
https://prismic.io/docs/technical-reference/prismicio-helpers
Apache License 2.0
15 stars 9 forks source link

`prismicH.asImageSrc` using `width` instead of `w` doesn't do anything #63

Closed Odas0R closed 1 year ago

Odas0R commented 1 year ago

Versions

Steps to reproduce

  const imgSrc = prismicH.asImageSrc(images[0]?.image, {
    width: 250, // does not work
    height: 250, // does not work
    q: 75,
    fm: "webp",
    fit: "crop",
  });

  const imgSrc = prismicH.asImageSrc(images[0]?.image, {
    w: 250, // works
    h: 250, // works
    q: 75,
    fm: "webp",
    fit: "crop",
  });

What is expected?

Using the param width and height optimize the image

What is actually happening?

The param width and height have no effect

github-actions[bot] commented 1 year ago

This issue has been labeled as a bug since it was created using the 🚨 Bug Report Template.

Hi there, thank you so much for the report!

Following our Maintenance Process, we will review your bug report and get back to you next Wednesday. To ensure a smooth review of your issue and avoid unnecessary delays, please make sure your issue includes the following:

If you have identified the cause of the bug described in your report and know how to fix it, you're more than welcome to open a pull request addressing it. Check out our quick start guide for a simple contribution process.

If you think your issue is a question (not a bug) and would like quicker support, please close this issue and forward it to an appropriate section on our community forum: https://community.prismic.io

- The Prismic Open-Source Team

lihbr commented 1 year ago

Hey there, thank you so much for contributing. I'm sorry we failed to get back to you in a timely manner.

I tried reproducing without success, those tests pass as expected (committed version: https://github.com/prismicio/prismic-helpers/commit/5ee387a4abbefdb50970cc80585795af11fdd752 /CI results: https://github.com/prismicio/prismic-helpers/actions/runs/5465804619/jobs/9949788226):

expect(
    asImageSrc(field, {
        w: 250,
        h: 250,
        q: 75,
        fm: "webp",
        fit: "crop",
    }),
).toBe(`${field.url}&w=250&h=250&q=75&fm=webp&fit=crop`);
expect(
    asImageSrc(field, {
        width: 250,
        height: 250,
        q: 75,
        fm: "webp",
        fit: "crop",
    }),
).toBe(`${field.url}&width=250&height=250&q=75&fm=webp&fit=crop`);

Equivalent images appear to be rendered as expected:

I'm confused if I got your issue correctly, maybe this was a regression back then on Imgix's end? Well let me know, I'm closing it for now but happy to reopen~