Remove unused Cloudflare image resizing function (#4507)

This commit is contained in:
conico974
2026-08-17 17:26:32 +02:00
committed by GitHub
parent d33e570bc7
commit fb01dc9ecb
2 changed files with 0 additions and 35 deletions
@@ -1,33 +0,0 @@
import type { CloudflareImageOptions } from './types';
import { copyImageResponse } from './utils';
import { getLogger } from '@/lib/logger';
/**
* Resize an image by doing a request to the image itself using the Cloudflare fetch.
* https://developers.cloudflare.com/images/transform-images/transform-via-workers/
*/
export async function resizeImageWithCFFetch(
input: string,
options: CloudflareImageOptions & {
signal?: AbortSignal;
}
): Promise<Response> {
const { signal, ...resizeOptions } = options;
const logger = getLogger().subLogger('imageResizing');
logger.log(`resize image using cf-fetch: ${input}`);
return copyImageResponse(
await fetch(input, {
headers: {
// Pass the `Accept` header, as Cloudflare uses this to validate the format.
Accept:
resizeOptions.format === 'json'
? 'application/json'
: `image/${resizeOptions.format || 'jpeg'}`,
},
signal,
cf: { image: resizeOptions },
})
);
}
@@ -3,7 +3,6 @@ import assertNever from 'assert-never';
import { GITBOOK_IMAGE_RESIZE_MODE } from '../../env';
import { SizableImageAction, checkIsSizableImageURL } from '../checkIsSizableImageURL';
import { resizeImageWithCFFetch } from './cf-fetch';
import { resizeImageWithGitbookServices } from './gitbook-service';
import type { CloudflareImageJsonFormat, CloudflareImageOptions } from './types';
import { getLogger } from '@/lib/logger';
@@ -73,7 +72,6 @@ export async function resizeImage(
switch (GITBOOK_IMAGE_RESIZE_MODE) {
case 'cf-fetch':
return resizeImageWithCFFetch(input, options);
case 'gitbook-service':
case 'cdn-cgi':
return resizeImageWithGitbookServices(input, options);