Skip to content

[Bug] High resolution displays still render low resolution images? #327

@cprussin

Description

@cprussin

Bug Report

Describe the bug

It seems that in the srcset generated using this library, the 2x size uses the same actual image as the 1x size. I know very little about the code in this lib, but it appears this is caused by using widthResize to generate higher-resolution URLs in the loader, but then ignoring widthResize if it's bigger than the user-specified width.

Is this a regression?

I don't see any evidence that it is but I know little about the history of this library

Steps To Reproduce the error

  1. Create an image with a width and height
  2. Observe that in the srcset, the 2x src is the same as the 1x src
  3. As a result, observe that on high-DPI displays, the image looks blurry, unless you manually set the image dimensions to double the required size and then downsize in css or something

Expected behaviour

Ideally I think we should leverage the newly added DRP support and specify a DPR that matches the multiplier calculated by the loader, instead of using resizes.

CodeSandbox or Live Example of Bug

My cloudinary instance is private so I'd need to spin up a public one to get a minimal repro together. It feels like this issue is straightforward enough that it's not worth the effort, but let me know if you think it would be valuable in deciding what to do here and I'm happy to put the effort in.

Your environment

$ uname -a
Darwin Connor-Prussin-C4P793YFRV.local 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:41:28 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T6020 arm64 arm Darwin
$ node --version
v18.17.0
$ npm --version
9.6.7
$ pnpm --version
8.6.11
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version
Google Chrome 118.0.5993.88 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions