diff --git a/backend/app/routers/content.py b/backend/app/routers/content.py index 5bc2cb6..072d2d3 100644 --- a/backend/app/routers/content.py +++ b/backend/app/routers/content.py @@ -171,12 +171,35 @@ def generate_content( text, affiliate_link_dicts, character.topics or [] ) + # Generate image if requested + image_url = None + content_types = request.content_types if request.content_types else [request.content_type] + if "image" in content_types: + img_provider_name = _get_setting(db, "image_provider", current_user.id) + img_api_key = _get_setting(db, "image_api_key", current_user.id) + if img_provider_name and img_api_key: + try: + img_provider = get_image_provider(img_provider_name, img_api_key) + visual_style = character.visual_style or {} + style_desc = visual_style.get("description", "") + img_prompt = ( + f"Social media image for a {character.niche} content creator. " + f"Topic: {request.topic_hint or text[:100]}. " + f"Style: {style_desc} professional, clean, engaging.".strip() + ) + image_url = img_provider.generate(img_prompt, size="1024x1024") + except Exception: + pass # Image generation failed, continue with text only + + effective_type = "text+image" if image_url else "text" + post = Post( batch_id=batch_id, character_id=character.id, user_id=current_user.id, - content_type=request.content_type, + content_type=effective_type, text_content=text, + image_url=image_url, hashtags=hashtags, affiliate_links_used=affiliate_links_used, llm_provider=provider_name, diff --git a/frontend/src/components/ContentPage.jsx b/frontend/src/components/ContentPage.jsx index 2099b99..2b68ef9 100644 --- a/frontend/src/components/ContentPage.jsx +++ b/frontend/src/components/ContentPage.jsx @@ -442,6 +442,10 @@ export default function ContentPage() { ) : (
+ {generated.image_url && ( + Immagine generata + )}

{generated.text_content}