I'm attempting to utilize the upload field in the following manner:
upload: {
staticURL: '/images',
staticDir: 'images',
imageSizes: [
{
name: 'large',
height: 890,
width: undefined,
},
{
name: 'small',
height: 408,
width: undefined
},
...
I anticipate that the width will be automatically computed based on the specified height. However, I observed that both values are returned as null.
This is just an issue with the data that is returned then? Are you able to see if the image file that is written is the expected dimensions?
We shuttle these values off to sharp to handle. If you're trying to maintain the aspect ratio of the image, I believe it's the
height
value that needs to be set to
undefined
, not
width
The issue was that the desired size was larger than the uploaded image size, which is why the image didn't get resized.
I would recommend to leave a note for that in the docs
Ah, yes this does sometimes trip people up.
It might be worth a discussion if resizing no matter what should be the default.
Thoughts on that?
yea, I think upscaling is probably not ideal so I would leave it as is it right now.
also, it would be great if we have an option like "forceResize"
I can add a PR for that if you want
Go ahead and open a GH discussion, and we can all discuss the feature 👍
Star
Discord
online
Get dedicated engineering support directly from the Payload team.