From 9473aecba725e726037f40b2d2e584af48e9ab7b Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Sun, 25 Oct 2026 09:29:24 +0000 Subject: [PATCH 1/6] cap image intrinsic width fixes 17367 --- src/remark-image-processing.js | 11 +++++++++-- src/remark-image-processing.spec.js | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/remark-image-processing.js b/src/remark-image-processing.js index bca3963cf9a13..cdb406f40f7ce 100644 --- a/src/remark-image-processing.js +++ b/src/remark-image-processing.js @@ -5,9 +5,11 @@ import path from 'path'; import sharp from 'sharp'; import {visit} from 'unist-util-visit'; +const MAX_IMAGE_WIDTH = 900; + /** * Processes images in MDX content: - * 1. Appends image dimensions as a URL hash (for next/image sizing) + * 1. Appends image dimensions capped at 900px wide as a URL hash (for next/image sizing) * 2. Appends content hash as query param (for Vercel CDN cache busting) * * e.g. /img.png -> /img.png?v=abc12345#100x100 @@ -38,7 +40,12 @@ export default function remarkImageProcessing(options) { // Read file buffer once for both operations to avoid redundant disk I/O const imageBuffer = readFileSync(fullImagePath); - const {width, height} = await sharp(imageBuffer).metadata(); + let {width, height} = await sharp(imageBuffer).metadata(); + if (width > MAX_IMAGE_WIDTH) { + // cap new height proportionally to MAX_IMAGE_WIDTH + height = Math.max(1, Math.round((height * MAX_IMAGE_WIDTH) / width)); + width = MAX_IMAGE_WIDTH; + } const contentHash = createHash('md5') .update(imageBuffer) .digest('hex') diff --git a/src/remark-image-processing.spec.js b/src/remark-image-processing.spec.js index 8b9213fdda42a..6a4d0f9c131e9 100644 --- a/src/remark-image-processing.spec.js +++ b/src/remark-image-processing.spec.js @@ -39,6 +39,10 @@ describe('remarkImageProcessing', () => { [path.join(sourceFolder, 'relative.png'), await createImage(200, 150, 'png')], [path.join(sourceFolder, 'photo.jpg'), await createImage(64, 48, 'jpeg')], [path.join(sourceFolder, 'animation.gif'), await createImage(30, 20, 'gif')], + [path.join(sourceFolder, 'wide.png'), await createImage(2942, 1360, 'png')], + [path.join(sourceFolder, 'boundary.png'), await createImage(900, 600, 'png')], + [path.join(sourceFolder, 'thin.png'), await createImage(1801, 1, 'png')], + [path.join(sourceFolder, 'portrait.png'), await createImage(600, 1200, 'png')], [ path.join(sourceFolder, 'icon.svg'), Buffer.from( @@ -76,6 +80,21 @@ describe('remarkImageProcessing', () => { expect(node.url).toBe(`/img/public.png?v=${hashes['public.png']}#120x80`); }); + it.each([ + ['wide.png', '900x416'], + ['boundary.png', '900x600'], + ['thin.png', '900x1'], + ['portrait.png', '600x1200'], + ])( + 'caps width without upscaling and preserves the content hash for %s', + async (fixture, size) => { + const node = imageNode(`./${fixture}`); + await transform(tree(node)); + + expect(node.url).toBe(`./${fixture}?v=${hashes[fixture]}#${size}`); + } + ); + it.each(['https://example.com/img.png', 'http://example.com/img.png', '//cdn/img.png'])( 'leaves the external image %s untouched', async url => { From 234c36bd2fb34e7224f7215083d55deed0cd33c6 Mon Sep 17 00:00:00 2001 From: Sergiy Dybskiy Date: Mon, 26 Oct 2026 12:02:42 -0700 Subject: [PATCH 2/6] fix(mdx): Keep image size hash through esbuild bundling esbuild's file loader drops the query and hash from image imports, so the `#WxH` size added by remark-image-processing never reached DocImage and every docs image rendered as a plain instead of next/image. Add remarkImageSizeToSrc after remark-mdx-images to append the size hash to the imported src expression, so the capped width takes effect. Co-authored-by: Claude --- src/mdx.ts | 3 +- src/remark-image-processing.js | 53 +++++++++++++++++++++++++++++ src/remark-image-processing.spec.js | 38 ++++++++++++++++++++- 3 files changed, 92 insertions(+), 2 deletions(-) diff --git a/src/mdx.ts b/src/mdx.ts index 9f61d9c722181..37207d7a7ce02 100644 --- a/src/mdx.ts +++ b/src/mdx.ts @@ -38,7 +38,7 @@ import remarkCodeTitles from './remark-code-title'; import remarkComponentSpacing from './remark-component-spacing'; import remarkExtractFrontmatter from './remark-extract-frontmatter'; import remarkFormatCodeBlocks from './remark-format-code'; -import remarkImageProcessing from './remark-image-processing'; +import remarkImageProcessing, {remarkImageSizeToSrc} from './remark-image-processing'; import remarkImageResize from './remark-image-resize'; import remarkTocHeadings, {TocNode} from './remark-toc-headings'; import remarkVariables from './remark-variables'; @@ -810,6 +810,7 @@ export async function getFileBySlug(slug: string): Promise { {sourceFolder: cwd, publicFolder: path.join(root, 'public')}, ], remarkMdxImages, + remarkImageSizeToSrc, remarkImageResize, remarkCodeTitles, remarkCodeTabs, diff --git a/src/remark-image-processing.js b/src/remark-image-processing.js index cdb406f40f7ce..dfd6f77c68df4 100644 --- a/src/remark-image-processing.js +++ b/src/remark-image-processing.js @@ -57,3 +57,56 @@ export default function remarkImageProcessing(options) { ); }; } + +/** + * esbuild's file loader drops the query and hash from image imports, so the + * size hash added above never reaches docImage.tsx. Run this after + * remark-mdx-images to append the size hash to the imported `src` instead. + * + * e.g. -> + */ +export function remarkImageSizeToSrc() { + return tree => { + const sizeByImport = new Map(); + visit(tree, 'mdxjsEsm', node => { + for (const statement of node.data?.estree?.body ?? []) { + const size = /#(\d+x\d+)$/.exec(statement.source?.value)?.[1]; + if (statement.type === 'ImportDeclaration' && size) { + sizeByImport.set(statement.specifiers[0].local.name, size); + } + } + }); + + visit(tree, {type: 'mdxJsxTextElement', name: 'img'}, node => { + const src = node.attributes.find(attribute => attribute.name === 'src'); + const name = src?.value?.data?.estree?.body[0]?.expression?.name; + const size = sizeByImport.get(name); + if (!size) { + return; + } + + src.value = { + type: 'mdxJsxAttributeValueExpression', + value: `${name} + "#${size}"`, + data: { + estree: { + type: 'Program', + sourceType: 'module', + comments: [], + body: [ + { + type: 'ExpressionStatement', + expression: { + type: 'BinaryExpression', + operator: '+', + left: {type: 'Identifier', name}, + right: {type: 'Literal', value: `#${size}`}, + }, + }, + ], + }, + }, + }; + }); + }; +} diff --git a/src/remark-image-processing.spec.js b/src/remark-image-processing.spec.js index 6a4d0f9c131e9..2ccb643725a62 100644 --- a/src/remark-image-processing.spec.js +++ b/src/remark-image-processing.spec.js @@ -3,10 +3,12 @@ import {mkdirSync, mkdtempSync, rmSync, writeFileSync} from 'node:fs'; import {tmpdir} from 'node:os'; import path from 'node:path'; +import {bundleMDX} from 'mdx-bundler'; +import remarkMdxImages from 'remark-mdx-images'; import sharp from 'sharp'; import {beforeAll, describe, expect, it} from 'vitest'; -import remarkImageProcessing from './remark-image-processing'; +import remarkImageProcessing, {remarkImageSizeToSrc} from './remark-image-processing'; const createImage = (width, height, format) => { const image = sharp({ @@ -119,3 +121,37 @@ describe('remarkImageProcessing', () => { await expect(transform(tree(imageNode('./nope.png')))).rejects.toThrow(/ENOENT/); }); }); + +describe('remarkImageSizeToSrc', () => { + it('keeps the size hash after esbuild bundles the image', async () => { + const root = mkdtempSync(path.join(tmpdir(), 'remark-image-size-to-src-')); + writeFileSync(path.join(root, 'wide.png'), await createImage(2942, 1360, 'png')); + + try { + const {code} = await bundleMDX({ + source: '![wide](./wide.png)', + cwd: root, + mdxOptions(options) { + options.remarkPlugins = [ + [remarkImageProcessing, {publicFolder: root, sourceFolder: root}], + remarkMdxImages, + remarkImageSizeToSrc, + ]; + return options; + }, + esbuildOptions(options) { + options.loader = {...options.loader, '.png': 'file'}; + options.outdir = path.join(root, 'out'); + options.publicPath = '/mdx-images'; + options.write = true; + return options; + }, + }); + + expect(code).toMatch(/"\/mdx-images\/wide-[A-Z0-9]+\.png"/); + expect(code).toContain('"#900x416"'); + } finally { + rmSync(root, {recursive: true, force: true}); + } + }); +}); From 4b47abe5527a86c8d3776ab6144ed939e1243cfe Mon Sep 17 00:00:00 2001 From: Sergiy Dybskiy Date: Mon, 26 Oct 2026 13:40:19 -0700 Subject: [PATCH 3/6] revert: Keep image size hash through esbuild bundling This reverts commit 234c36bd2. Routing every docs image through next/image shrinks screenshots on 2x screens and in the lightbox, and needs a longer minimumCacheTTL to avoid repeat transformation costs. Reverting until the PR author picks a direction. Co-authored-by: Claude --- src/mdx.ts | 3 +- src/remark-image-processing.js | 53 ----------------------------- src/remark-image-processing.spec.js | 38 +-------------------- 3 files changed, 2 insertions(+), 92 deletions(-) diff --git a/src/mdx.ts b/src/mdx.ts index 37207d7a7ce02..9f61d9c722181 100644 --- a/src/mdx.ts +++ b/src/mdx.ts @@ -38,7 +38,7 @@ import remarkCodeTitles from './remark-code-title'; import remarkComponentSpacing from './remark-component-spacing'; import remarkExtractFrontmatter from './remark-extract-frontmatter'; import remarkFormatCodeBlocks from './remark-format-code'; -import remarkImageProcessing, {remarkImageSizeToSrc} from './remark-image-processing'; +import remarkImageProcessing from './remark-image-processing'; import remarkImageResize from './remark-image-resize'; import remarkTocHeadings, {TocNode} from './remark-toc-headings'; import remarkVariables from './remark-variables'; @@ -810,7 +810,6 @@ export async function getFileBySlug(slug: string): Promise { {sourceFolder: cwd, publicFolder: path.join(root, 'public')}, ], remarkMdxImages, - remarkImageSizeToSrc, remarkImageResize, remarkCodeTitles, remarkCodeTabs, diff --git a/src/remark-image-processing.js b/src/remark-image-processing.js index dfd6f77c68df4..cdb406f40f7ce 100644 --- a/src/remark-image-processing.js +++ b/src/remark-image-processing.js @@ -57,56 +57,3 @@ export default function remarkImageProcessing(options) { ); }; } - -/** - * esbuild's file loader drops the query and hash from image imports, so the - * size hash added above never reaches docImage.tsx. Run this after - * remark-mdx-images to append the size hash to the imported `src` instead. - * - * e.g. -> - */ -export function remarkImageSizeToSrc() { - return tree => { - const sizeByImport = new Map(); - visit(tree, 'mdxjsEsm', node => { - for (const statement of node.data?.estree?.body ?? []) { - const size = /#(\d+x\d+)$/.exec(statement.source?.value)?.[1]; - if (statement.type === 'ImportDeclaration' && size) { - sizeByImport.set(statement.specifiers[0].local.name, size); - } - } - }); - - visit(tree, {type: 'mdxJsxTextElement', name: 'img'}, node => { - const src = node.attributes.find(attribute => attribute.name === 'src'); - const name = src?.value?.data?.estree?.body[0]?.expression?.name; - const size = sizeByImport.get(name); - if (!size) { - return; - } - - src.value = { - type: 'mdxJsxAttributeValueExpression', - value: `${name} + "#${size}"`, - data: { - estree: { - type: 'Program', - sourceType: 'module', - comments: [], - body: [ - { - type: 'ExpressionStatement', - expression: { - type: 'BinaryExpression', - operator: '+', - left: {type: 'Identifier', name}, - right: {type: 'Literal', value: `#${size}`}, - }, - }, - ], - }, - }, - }; - }); - }; -} diff --git a/src/remark-image-processing.spec.js b/src/remark-image-processing.spec.js index 2ccb643725a62..6a4d0f9c131e9 100644 --- a/src/remark-image-processing.spec.js +++ b/src/remark-image-processing.spec.js @@ -3,12 +3,10 @@ import {mkdirSync, mkdtempSync, rmSync, writeFileSync} from 'node:fs'; import {tmpdir} from 'node:os'; import path from 'node:path'; -import {bundleMDX} from 'mdx-bundler'; -import remarkMdxImages from 'remark-mdx-images'; import sharp from 'sharp'; import {beforeAll, describe, expect, it} from 'vitest'; -import remarkImageProcessing, {remarkImageSizeToSrc} from './remark-image-processing'; +import remarkImageProcessing from './remark-image-processing'; const createImage = (width, height, format) => { const image = sharp({ @@ -121,37 +119,3 @@ describe('remarkImageProcessing', () => { await expect(transform(tree(imageNode('./nope.png')))).rejects.toThrow(/ENOENT/); }); }); - -describe('remarkImageSizeToSrc', () => { - it('keeps the size hash after esbuild bundles the image', async () => { - const root = mkdtempSync(path.join(tmpdir(), 'remark-image-size-to-src-')); - writeFileSync(path.join(root, 'wide.png'), await createImage(2942, 1360, 'png')); - - try { - const {code} = await bundleMDX({ - source: '![wide](./wide.png)', - cwd: root, - mdxOptions(options) { - options.remarkPlugins = [ - [remarkImageProcessing, {publicFolder: root, sourceFolder: root}], - remarkMdxImages, - remarkImageSizeToSrc, - ]; - return options; - }, - esbuildOptions(options) { - options.loader = {...options.loader, '.png': 'file'}; - options.outdir = path.join(root, 'out'); - options.publicPath = '/mdx-images'; - options.write = true; - return options; - }, - }); - - expect(code).toMatch(/"\/mdx-images\/wide-[A-Z0-9]+\.png"/); - expect(code).toContain('"#900x416"'); - } finally { - rmSync(root, {recursive: true, force: true}); - } - }); -}); From 59a90e78630115947294a10cf9f30be5ef14da41 Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Mon, 26 Oct 2026 20:18:40 +0000 Subject: [PATCH 4/6] preserve image dimensions through MDX bundling --- src/components/docImage/index.tsx | 22 +++----- src/components/imageLightbox/index.tsx | 24 ++++---- src/remark-image-processing.js | 3 +- src/remark-image-processing.spec.js | 78 +++++++++++++++++++++++++- src/remark-image-resize.js | 40 ++++++++++++- 5 files changed, 134 insertions(+), 33 deletions(-) diff --git a/src/components/docImage/index.tsx b/src/components/docImage/index.tsx index 674e1a8d55aac..3765ac398fb31 100644 --- a/src/components/docImage/index.tsx +++ b/src/components/docImage/index.tsx @@ -98,20 +98,13 @@ export default function DocImage({ imgPath = finalSrc; } - // Prefer explicit props (coming from MDX attributes) over hash-based dimensions. - // If either width or height prop is provided, treat as manual sizing. - const manualWidth = parseDimension(propsWidth); - const manualHeight = parseDimension(propsHeight); - - // If either width or height is specified manually, ignore any hash dimensions entirely - const hasDimensionOverrides = manualWidth != null || manualHeight != null; - const hashDimensions = hasDimensionOverrides ? [] : parseDimensionsFromHash(src); - - const inferredWidth = hashDimensions[0] > 0 ? hashDimensions[0] : undefined; - const width = hasDimensionOverrides ? manualWidth : inferredWidth; - - const inferredHeight = hashDimensions[1] > 0 ? hashDimensions[1] : undefined; - const height = hasDimensionOverrides ? manualHeight : inferredHeight; + // JSX dimensions replace both hash dimensions, even for a single-axis override. + const parsedWidth = parseDimension(propsWidth); + const parsedHeight = parseDimension(propsHeight); + const [width, height] = + parsedWidth != null || parsedHeight != null + ? [parsedWidth, parsedHeight] + : parseDimensionsFromHash(src); return ( ); diff --git a/src/components/imageLightbox/index.tsx b/src/components/imageLightbox/index.tsx index 602f1d025e37e..763a823207c82 100644 --- a/src/components/imageLightbox/index.tsx +++ b/src/components/imageLightbox/index.tsx @@ -12,7 +12,6 @@ interface ImageLightboxProps extends Omit< alt: string; imgPath: string; src: string; - hasDimensionOverrides?: boolean; height?: number; width?: number; } @@ -53,7 +52,6 @@ export function ImageLightbox({ width, height, imgPath, - hasDimensionOverrides: hasDimensionOverrides = false, style, className, ...props @@ -98,19 +96,15 @@ export function ImageLightbox({ ? className : 'max-h-[90vh] max-w-[90vw] object-contain'; - // Apply sizing: - // - If manual: set only provided dimension(s); missing one becomes 'auto' - // - Else: default responsive - // TODO: support other units for overrides + // Fit the resolved width to the container; height follows the aspect ratio. + // Height-only overrides retain their requested height. const imageStyle = isInline - ? hasDimensionOverrides - ? { - width: width != null ? `${width}px` : 'auto', - height: height != null ? `${height}px` : 'auto', - maxWidth: 'min(100%, 1000px)', - ...style, - } - : {width: 'auto', maxWidth: 'min(100%, 1000px)', height: 'auto', ...style} + ? { + width: width != null ? `min(100%, ${width}px)` : 'auto', + height: width == null && height != null ? `${height}px` : 'auto', + maxWidth: '100%', + ...style, + } : {width: 'auto', height: 'auto'}; if (shouldUseNextImage && dimensions) { @@ -131,6 +125,8 @@ export function ImageLightbox({ /* eslint-disable-next-line @next/next/no-img-element */ {alt} /img.png?v=abc12345#100x100 * - * The size (#WxH) is consumed by docImage.tsx and passed down to next/image. + * For relative imports, remark-image-resize copies #WxH to JSX attributes before + * the bundler strips the hash. DocImage reads the hash for public asset URLs. * The content hash (?v=xxx) ensures browsers/CDN fetch fresh images when content changes. */ export default function remarkImageProcessing(options) { diff --git a/src/remark-image-processing.spec.js b/src/remark-image-processing.spec.js index 6a4d0f9c131e9..c28316bf3a605 100644 --- a/src/remark-image-processing.spec.js +++ b/src/remark-image-processing.spec.js @@ -3,10 +3,30 @@ import {mkdirSync, mkdtempSync, rmSync, writeFileSync} from 'node:fs'; import {tmpdir} from 'node:os'; import path from 'node:path'; +import {select} from 'hast-util-select'; +import {bundleMDX} from 'mdx-bundler'; +import {getMDXComponent} from 'mdx-bundler/client'; +import React from 'react'; +import {renderToStaticMarkup} from 'react-dom/server'; +import rehypeParse from 'rehype-parse'; +import remarkMdxImages from 'remark-mdx-images'; import sharp from 'sharp'; -import {beforeAll, describe, expect, it} from 'vitest'; +import {unified} from 'unified'; +import {afterAll, beforeAll, describe, expect, it, vi} from 'vitest'; +import DocImage from './components/docImage'; import remarkImageProcessing from './remark-image-processing'; +import remarkImageResize from './remark-image-resize'; + +vi.mock('server-only', () => ({})); + +vi.mock('sentry-docs/serverContext', () => ({ + serverContext: () => ({path: []}), +})); + +// Vitest uses the classic JSX transform for the application components. +vi.stubGlobal('React', React); +afterAll(() => vi.unstubAllGlobals()); const createImage = (width, height, format) => { const image = sharp({ @@ -118,4 +138,60 @@ describe('remarkImageProcessing', () => { it('rejects when the image is missing', async () => { await expect(transform(tree(imageNode('./nope.png')))).rejects.toThrow(/ENOENT/); }); + + async function renderImage(suffix) { + const {code} = await bundleMDX({ + source: `![Fixture${suffix}](./wide.png)`, + cwd: sourceFolder, + mdxOptions(options) { + options.remarkPlugins = [ + ...(options.remarkPlugins ?? []), + [remarkImageProcessing, {sourceFolder, publicFolder}], + remarkMdxImages, + remarkImageResize, + ]; + return options; + }, + esbuildOptions(options) { + options.loader = {...options.loader, '.png': 'file'}; + options.outdir = path.join(sourceFolder, 'output'); + options.write = true; + return options; + }, + }); + const Content = getMDXComponent(code); + const html = renderToStaticMarkup( + React.createElement(Content, {components: {img: DocImage}}) + ); + return select('img', unified().use(rehypeParse, {fragment: true}).parse(html)) + .properties; + } + + describe('MDX image bundling and rendering', () => { + it.each` + sizing | suffix | width | height + ${'inferred'} | ${''} | ${900} | ${416} + ${'width only'} | ${' =300x'} | ${300} | ${undefined} + ${'height only'} | ${' =x200'} | ${undefined} | ${200} + ${'both axes'} | ${' =300x200'} | ${300} | ${200} + `( + 'preserves $sizing sizing through bundling and rendering', + async ({suffix, width, height}) => { + const image = await renderImage(suffix); + + expect(image.width).toBe(width); + expect(image.height).toBe(height); + expect(image.alt).toBe('Fixture'); + expect(image.style).toContain( + `width:${width ? `min(100%, ${width}px)` : 'auto'};` + ); + expect(image.style).toContain( + `height:${!width && height ? `${height}px` : 'auto'}` + ); + expect(image.srcSet).toEqual( + width && height ? expect.stringContaining('/_next/image') : undefined + ); + } + ); + }); }); diff --git a/src/remark-image-resize.js b/src/remark-image-resize.js index d32f1d073b9f1..870b641ba29d2 100644 --- a/src/remark-image-resize.js +++ b/src/remark-image-resize.js @@ -15,10 +15,29 @@ const SIZE_FROM_ALT_RE = /\s*=\s*(?:(\d+)\s*x\s*(\d+)|(\d+)\s*x|x\s*(\d+))\s*$/; * Behavior: * - Extracts the trailing "=WxH" (width-only/height-only also supported). * - Cleans the ALT text by removing the size suffix. - * - Adds numeric `width`/`height` attributes to the element. + * - Manual sizes replace inferred dimensions, including width-only/height-only sizes. + * - Copies inferred dimensions from imports to JSX before the bundler strips URL hashes. */ export default function remarkImageResize() { - return tree => + return tree => { + // remember hash dimensions for each image import + const dimensionsByImport = new Map(); + visit(tree, 'mdxjsEsm', node => { + for (const declaration of node.data?.estree?.body ?? []) { + if (declaration.type !== 'ImportDeclaration') continue; + const dimensions = declaration.source.value.match(/#(\d+)x(\d+)$/); + if (dimensions) { + for (const specifier of declaration.specifiers) { + dimensionsByImport.set( + specifier.local.name, + // take the captured groups from the regex match (ie width and height) + dimensions.slice(1) + ); + } + } + } + }); + visit(tree, {type: 'mdxJsxTextElement', name: 'img'}, node => { // Handle MDX JSX produced by remark-mdx-images const altIndex = node.attributes.findIndex(a => a && a.name === 'alt'); @@ -44,7 +63,24 @@ export default function remarkImageResize() { node.attributes.push({type: 'mdxJsxAttribute', name: 'width', value: wStr}); if (hStr) node.attributes.push({type: 'mdxJsxAttribute', name: 'height', value: hStr}); + return; } } + + // inject inferred dimensions if not already manually overridden as width and height attributes + if ( + node.attributes.some(attribute => ['width', 'height'].includes(attribute.name)) + ) { + return; + } + const src = node.attributes.find(attribute => attribute.name === 'src'); + const dimensions = dimensionsByImport.get(src?.value?.value); + if (dimensions) { + node.attributes.push( + {type: 'mdxJsxAttribute', name: 'width', value: dimensions[0]}, + {type: 'mdxJsxAttribute', name: 'height', value: dimensions[1]} + ); + } }); + }; } From 2474c23363daa7f62bf4d1d66bcf45f88fed25af Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Mon, 26 Oct 2026 21:06:03 +0000 Subject: [PATCH 5/6] cache images for one day --- next.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/next.config.ts b/next.config.ts index 583078c3a45fa..81b72f324a280 100644 --- a/next.config.ts +++ b/next.config.ts @@ -103,6 +103,9 @@ if ( const nextConfig = { pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx', 'mdx'], trailingSlash: true, + images: { + minimumCacheTTL: 86400, // 1 day + }, serverExternalPackages: [ 'rehype-preset-minify', 'esbuild', From 929f79af81c1a95442390529003c4674c7f74c3d Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Mon, 26 Oct 2026 21:11:31 +0000 Subject: [PATCH 6/6] dedupe next images config --- next.config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/next.config.ts b/next.config.ts index 81b72f324a280..d97a2cf8e000d 100644 --- a/next.config.ts +++ b/next.config.ts @@ -103,9 +103,6 @@ if ( const nextConfig = { pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx', 'mdx'], trailingSlash: true, - images: { - minimumCacheTTL: 86400, // 1 day - }, serverExternalPackages: [ 'rehype-preset-minify', 'esbuild', @@ -127,6 +124,7 @@ const nextConfig = { images: { contentDispositionType: 'inline', // "open image in new tab" instead of downloading remotePatterns: REMOTE_IMAGE_PATTERNS, + minimumCacheTTL: 86400, // 1 day }, webpack: (config, options) => { config.plugins.push(