Replies: 1 comment
-
Hi Scott, Apologies for the late response. I think specifying height is definitely something that can be added to this package. Also, since In the meantime, I just found a fork of Remix-Image on npm that looks like it may support specifying image height. I have not tested it myself, but feel free to try. Hopefully, we can add height and additional media query support to this package soon! Here is the npm link, with the relevant changes being shown on the GitHub fork here. If you would like to test additional media queries, try following the steps below, and let me know the results!
You will need to modify the hook to use a ResponsiveSize type of something along the following: export type ResponsiveSize = {
size: {
width: number;
height?: number;
};
maxWidth?: number;
minWidth?: number;
}; Then you will need to allow this new media query to be used in the generated remix-image/src/hooks/responsiveImage.ts Line 44 in 5015ec2 const sizes = [...responsive]
.sort((resp1, resp2) => resp1.size.width - resp2.size.width)
.map((resp) =>
resp.maxWidth
? `(max-width: ${resp.maxWidth}px) ${resp.size.width}px` // <------ come up with new code to allow max-width or min-width
: `${resp.size.width}px`
);
|
Beta Was this translation helpful? Give feedback.
-
While using Responsive Sizes, I've run into some snags that make things tedious to set up for my use-case.
Perhaps some of this would be solved by getting close to the
next/image
impl - #9height
. A lot of times, I won't know the width of an element because that is dynamic but I will limit the height of the images. To get around the limitation ofwidth
being required, I have to manually calculate what the width should be, based on the height I desire. Is there a reason we can't provideheight
and allow thewidth
to be derived?Example with only-
height
support.min-width
to match things like the tailwind breakpoints. I would prefer to say "use this image", "use this image for large screens", and finally "use this other image for extra large screens". I can still accomplish this withExample with
minWidth
support.Beta Was this translation helpful? Give feedback.
All reactions