I wan to create a code component that displays an image from the user, with some additional transformations. I’ve managed to do this, but it’s not satisfactory:
PLASMIC.registerComponent(MyImage, {
name: "My image",
props: {
imageUrl: 'imageUrl',
alt: 'string',
title: 'string',
imgHeight: 'number',
imgWidth: 'number',
}
});
(--------------)
interface MyImageProps {
className: string,
imageUrl?: string,
alt?: string,
title?: string,
imgHeight: number,
imgWidth: number,
}
export function MyImage({ className,
imageUrl,
alt,
title,
imgHeight,
imgWidth }: MyImageProps) {
/* eslint-disable @next/next/no-img-element */
return <div className={ className }>
<div className="MyClassToDoThings">
<img src={ image || "" }
alt={ alt || "" }
title={ title || "" }
width={ imgWidth || ""}
height={ imgHeight || ""} />
</div>
</div>
}