@@ -49,21 +49,24 @@ type ImageV3Props = {
4949 src : string ;
5050 alt : string ;
5151 children ?: never ;
52+ imgProps ?: React . HTMLProps < HTMLImageElement >
5253} & ImageTransformationProps ;
5354
5455interface ImageV2Props {
5556 src ?: never ;
57+ alt : string ;
5658 cldImg : UrlGenCloudinaryImage ;
5759 children ?: never ;
60+ imgProps ?: React . HTMLProps < HTMLImageElement >
5861}
5962
6063export type CloudinaryImageProps = ImageV3Props | ImageV2Props ;
6164
6265export const CloudinaryImage = forwardRef < HTMLImageElement , CloudinaryImageProps > (
6366 ( props , ref ) => {
6467 if ( props . cldImg ) {
65- const { cldImg, ...rest } = props ;
66- return < img src = { cldImg . toURL ( ) } { ...rest } ref = { ref } /> ;
68+ const { cldImg, alt , imgProps , ...rest } = props ;
69+ return < img { ... imgProps } src = { cldImg . toURL ( ) } alt = { alt } { ...rest } ref = { ref } /> ;
6770 }
6871 const transformationMap = {
6972 format : parseFormat ,
@@ -84,12 +87,12 @@ export const CloudinaryImage = forwardRef<HTMLImageElement, CloudinaryImageProps
8487 roundCorners : parseRoundCorners ,
8588 opacity : parseOpacity
8689 } satisfies TransformationMap < ImageTransformationProps > ;
87- const { src, alt, children, cldImg, ...rest } = props ;
90+ const { src, alt, children, cldImg, imgProps , ...rest } = props ;
8891 const { baseCloudUrl, assetPath } = parseCloudinaryUrlToParts ( src ) ;
8992 const transformationString = parsePropsToTransformationString ( {
9093 transformationProps : rest ,
9194 transformationMap
9295 } ) ;
9396
94- return < img src = { `${ baseCloudUrl } /${ transformationString } /${ assetPath } ` } alt = { alt } ref = { ref } /> ;
97+ return < img { ... imgProps } src = { `${ baseCloudUrl } /${ transformationString } /${ assetPath } ` } alt = { alt } ref = { ref } /> ;
9598 } ) ;
0 commit comments