Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

feat: add attribution to images generated by ai (#2477)

Bogdan Chadkin724ad6c9c317
diff --git a/packages/ai/src/image.ts b/packages/ai/src/image.ts
index 86f0434618..f3b21a5d30 100644
--- a/packages/ai/src/image.ts
+++ b/packages/ai/src/image.ts
@@ -109,6 +109,17 @@ const queryImageAndMutateInstance = async (
} else {
instance.props[srcIndex] = newSrc;
}
+ const title: EmbedTemplateProp = {
+ name: "title",
+ type: "string",
+ value: `Credit: ${result.photographer}`,
+ };
+ const titleIndex = instance.props.findIndex((prop) => prop.name === "title");
+ if (titleIndex === -1) {
+ instance.props.push(title);
+ } else {
+ instance.props[titleIndex] = title;
+ }
// prevent image deformation when ai specifies image size
const hasObjectFit = instance.styles?.some(
(styleDecl) => styleDecl.property === "objectFit"