@@ -33,8 +33,8 @@ function bytesToSize(bytes: number) {
3333const MAX_SIZE_FILTERS = {
3434 logo : 48 ,
3535 sm : 300 ,
36- md : 600 ,
37- lg : 1024 ,
36+ md : 1024 , // Increased from 600 to 1024 for better quality
37+ lg : 2048 , // Increased from 1024 to 2048 for better quality
3838} as const ;
3939
4040// Utility function to filter `srcSet` based on the `size`
@@ -115,6 +115,14 @@ export default function IdealImage(
115115 const isGifInEarlyReturn = typeof img === "string" ? img . endsWith ( '.gif' ) :
116116 ( typeof img === "object" && img !== null && typeof img . default === "string" && img . default . endsWith ( '.gif' ) ) ;
117117
118+ // Use 600px display size for md, even for GIFs
119+ const getGifDisplaySize = ( size : keyof typeof MAX_SIZE_FILTERS ) => {
120+ if ( size === "md" ) return 600 ;
121+ return MAX_SIZE_FILTERS [ size ] ;
122+ } ;
123+
124+ const gifDisplaySize = getGifDisplaySize ( size ) ;
125+
118126 const gifStyles = isGifInEarlyReturn ? (
119127 size === "lg"
120128 ? {
@@ -128,12 +136,12 @@ export default function IdealImage(
128136 }
129137 : size === "logo"
130138 ? {
131- width : `${ MAX_SIZE_FILTERS [ size ] } px` ,
139+ width : `${ gifDisplaySize } px` ,
132140 height : "auto" ,
133141 display : "block" ,
134142 }
135143 : {
136- maxWidth : `${ MAX_SIZE_FILTERS [ size ] } px` ,
144+ maxWidth : `${ gifDisplaySize } px` ,
137145 width : "auto" ,
138146 height : "auto" ,
139147 margin : "0 auto" ,
@@ -200,6 +208,15 @@ export default function IdealImage(
200208 const isGif = currentImage . path ?. toLowerCase ( ) . endsWith ( '.gif' ) || false ;
201209
202210 // Apply conditional styles based on the `size`
211+ // For md size, we want to display at 600px visual size but use 1024px source for quality
212+ const getDisplaySize = ( size : keyof typeof MAX_SIZE_FILTERS ) => {
213+ if ( size === "md" ) return 600 ; // Display md at 600px visual size
214+ if ( size === "lg" ) return "100%" ; // lg remains full width
215+ return MAX_SIZE_FILTERS [ size ] ; // logo and sm use their original sizes
216+ } ;
217+
218+ const displaySize = getDisplaySize ( size ) ;
219+
203220 const imageStyles : React . CSSProperties =
204221 size === "lg"
205222 ? {
@@ -213,19 +230,19 @@ export default function IdealImage(
213230 }
214231 : size == "logo"
215232 ? {
216- width : `${ MAX_SIZE_FILTERS [ size ] } px` ,
233+ width : `${ displaySize } px` ,
217234 display : "block" ,
218235 }
219236 : {
220- width : `${ MAX_SIZE_FILTERS [ size ] } px` ,
237+ width : `${ displaySize } px` ,
221238 margin : "0 auto" ,
222239 display : "block" ,
223240 boxShadow : border
224241 ? "0px 1px 8px -1px rgba(21, 21, 21, 0.20)"
225242 : "none" ,
226243 // For GIFs, add maxWidth and height auto to maintain aspect ratio
227244 ...( isGif && {
228- maxWidth : `${ MAX_SIZE_FILTERS [ size ] } px` ,
245+ maxWidth : `${ displaySize } px` ,
229246 width : "auto" ,
230247 height : "auto" ,
231248 } ) ,
0 commit comments