feat(ui): support resize_to when uploading images

This commit is contained in:
psychedelicious
2025-05-28 20:10:56 +10:00
parent 87a44a28ef
commit 845a321a43
2 changed files with 9 additions and 1 deletions

View File

@@ -270,12 +270,15 @@ export const imagesApi = api.injectEndpoints({
},
}),
uploadImage: build.mutation<ImageDTO, UploadImageArg>({
query: ({ file, image_category, is_intermediate, session_id, board_id, crop_visible, metadata }) => {
query: ({ file, image_category, is_intermediate, session_id, board_id, crop_visible, metadata, resize_to }) => {
const formData = new FormData();
formData.append('file', file);
if (metadata) {
formData.append('metadata', JSON.stringify(metadata));
}
if (resize_to) {
formData.append('resize_to', JSON.stringify(resize_to));
}
return {
url: buildImagesUrl('upload'),
method: 'POST',

View File

@@ -1,3 +1,4 @@
import type { Dimensions } from 'features/controlLayers/store/types';
import type { components, paths } from 'services/api/schema';
import type { JsonObject, SetRequired } from 'type-fest';
@@ -373,6 +374,10 @@ export type UploadImageArg = {
* Whether this is the first upload of a batch (used when displaying user feedback with toasts - ignored if the upload is silent)
*/
isFirstUploadOfBatch?: boolean;
/**
* If provided, the uploaded image will resized to the given dimensions.
*/
resize_to?: Dimensions;
};
export type ImageUploadEntryResponse = S['ImageUploadEntry'];