Josh-McFarlin / remix-image

A React component for responsive images in Remix
https://remix-image.mcfarl.in
MIT License
329 stars 24 forks source link

Cloudflare Image Resizing loader -- toFixed(2) syntax error #69

Closed themaxgross closed 8 months ago

themaxgross commented 1 year ago

Describe the bug

If no background is specified in loader options while using the CloudFlare Images loader, the service will error because of a syntax error.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

Load an image with default loader options and using <Image loader={cloudflareImagesLoader}>. Render the page. Expect the image not to render; CloudFlare Image Resizing responds with error message similar to:

CleanShot 2023-04-21 at 23 38 35

Expected behavior

It should show the image, I suppose

Screenshots or Videos

No response

Platform

I'm using OS X on a M1 Mac Mini in Arc browser (Chromium-based), but I suspect this'll happen regardless of environment

Additional context

I'm pretty sure the issue is targeted to how the rgba() values are being calculated -- specifically the .toFixed(2), which transforms zero like Number(0).toFixed(2) => "0.00". I wonder if tooling is available to help calculate these values, but I'm not sure. Leaving this bug report so the issue is noted -- I will try to find a fix if I can

themaxgross commented 8 months ago

Closing as stale