Image upload errors
-
Hey how are you again π
Sorry on all the messages but as i told you i test now your plugin with claude code and i find problems any new build
now i have error with the image uploads.
Localhost [wp_upload_media]picsum.photos
OUT
MCP error -32603: Exception::__construct(): Argument #2 ($code) must be of type int, string given
Image generation and external sideloading are both disabled in this local environment (no AI key; server has no outbound fetch β the upload errored on download). Rather than ship broken/fake images, I'll build the section visuals as native CSS/SVG art tuned to the industrial-tech brand (animated iso hero scene, velocity streaks, duotone industry plates with line-glyphs). This is fully rule-clean, animatable, and defensible under the creative-latitude brief. Noting it and moving on.Its look like Claude create an image but cant to upload the image via you functions.
And i know i have an option use API of Gemini or OpenAI and claude will generate photos with this APIs
The problem is little dangerous because you dont know how much image he will create and images is not cheap.
Have idea why the image upload function not working?
The page I need help with: [log in to see the link]
-
Hey! π Thanks for your patience with all this.
I’ve prepared a special build with a fix so you don’t have to touch any code. Download it here: https://drop.meowapps.com/d/R_tCKyxWRU
Then try the image upload through Claude Code again. I found a small issue that might affect images without a file extension (on picsum.photos, they don’t have one). On my end it wasn’t causing problems with the same AI Engine version and site as yours, but this new build at least fixes the fact that the real error wasn’t being shown (it was crashing with a secondary WordPress error instead). So now you’ll be able to see the actual error. Hope that makes sense! π
Let me know how it goes!
I have a couple more questions @tigroumeow , if you can help me:
First: Settings β File and Media
I left this option at its default setting, but I don’t really understand what it means. If you could explain it, I’d really appreciate it.
I already created an image, and I noticed that it was saved in the Media Library, so I’m confused about what this setting actually does.
This is what I currently have (default setting, screenshot):
Should I keep the default setting? Should I choose only Media Library to follow WordPress best practices? What should I do? I’m asking because I already generated an image, and it appears to have been saved in the Media Library anyway.
Second – Settings β AI: Also, I’m using Google AI Studio. I added Google under Settings β AI.
After that, I enabled the Video module under Modules, but I didn’t notice anything special. I found the Video Generator in the top-right corner, but it doesn’t let me choose Google as the video generation provider. (Only Open AI – Sora)
By the way, I also can’t choose Nano Banana Pro or any other image model like that for image generation.
Nano Banana Pro: it is supported. Its technical name is gemini-3-pro-image-preview. If it’s not showing in your list, go to your Google environment settings and refresh the model list, it should appear after that (your list was probably cached before this model existed). I also just fixed a related edge case for the next release, where a slightly different variant of the same model wasn’t being detected.
Video: this one’s honest news, there’s currently no working video option! π₯² OpenAI’s Sora was removed by OpenAI, and Google’s video (Veo) isn’t something AI Engine supports yet (I could, but I am not sure it’s actually useful to have this in AI Engine). So it’s not a setting you’re missing, the feature simply isn’t available right now.
Let me know if refreshing the models makes Nano Banana Pro show up!
Ah, and about the Settings in Files & Media:
- Media Library is the standard WordPress way. Images become normal media files you can reuse in posts, and they’re backed up with your site. Best for images you want to keep.
- Filesystem stores files outside the Media Library, which keeps it tidy, and it pairs with the Expiration option to auto-delete temporary files. This is handy for things like photos people upload into a chatbot that you don’t need to keep forever.
It’s actually really a personal choice.
Hey @tigroumeow how are you again, so 2 question i have left.
SettingsΒ inΒ Files & Media:
Ok, so for example, if Claude code build a website with the MCP connection and upload a photo, this setting apply to him as well? or this setting is only for the AI Engine chat for frontend? or backend as well?
Image Generation with AI Engine in the backend?
Its look like this setting is for frontend chat but i didnt understand if the apply to the MCP or image generation via the backend.
Webp option when generate images with AI Engine AI photo generator:
Its possible to generate AI images with your plugin and they will be generated as webp?
My problem is, if you generate a PNG and then convert it, is a problem. when the image generated, its go to the media library, and the image get a permalink, even if you delete the image, you still has the Permalink in the database. usually i tried to upload images 1 time and this is it, i avoid uploads garbage or duplication because even if i delete this images, is still has a permalink. so i be glad to hear if its possible.
Hi @123nadav π
It applies to any photo created via the AI Engine framework, so whether it’s the chatbot, Simple API, MCP, REST API, etc., everything goes through the same functions in the end. This setting lets you keep those images either in the Media Library or more hidden away in the filesystem. The MCP client is aware of this too. For example, if the image is on the filesystem and set to be deleted after 24 hours, the MCP client will still register it properly in the Media Library if it was meant to be used in a post. So “keeping” images created by AI Engine is more of a logging thing. If you (or the MCP client) actually intend to use them, they’ll be properly added to the Media Library π
The WebP limitation isn’t an AI Engine thing, it’s the AI providers themselves. They only output PNG or JPG. I think the right place for that optimization is when the image gets registered in the Media Library. Let the JPG or PNG expire, and your process can create a WebP or AVIF from it if that’s what you want.
Personally, I keep only JPGs and PNGs on my site and have WebP/AVIF generated dynamically on top without storing them on my server. There are a few solutions for that, but I use Perfect Images with EasyIO.
Hey @tigroumeow hey again.
About the WebP images, I found a solution. You can use the native PHP GD extension for image processing. Claude Code created a snippet that converts the images when they’re generated by the tool or via MCP.
Before the images receive their permalink, the snippet converts them to WebP. Here’s the snippet:
<?php
// WebP-convert AI Engine image generations ONLY β manual/other uploads untouched.
// AI Engine bypasses the WP upload pipeline (file_put_contents + wp_insert_post) and
// calls wp_generate_attachment_metadata right after the write, BEFORE it returns the
// URL (MCP path) or shows the draft (admin-UI path) β so we convert inside that call
// and nothing ever sees a non-webp URL.
// Gate: post_type mwai_image (admin-UI generator) OR the ai_<uniqid>.<digits> filename
// AI Engine stamps on MCP generations β both impossible to hit via manual upload.
// Gemini ships JPEG bytes in .png names β imagecreatefromstring, never *frompng.
// Anonymous closure on purpose: named functions in a persistent snippet deadlock
// Code Engine's validator on update (self-collision).
// wp_unique_filename on the .webp target is CRITICAL: AI Engine's own uniqueness loop
// only guards the original .png name. Two drafts saved under the same filename would
// otherwise share one .webp β deleting/discarding one draft then 404s the other.
add_filter('wp_generate_attachment_metadata', function ($metadata, $attachment_id) {
static $busy = false;
if ($busy || !function_exists('imagewebp')) return $metadata;
$file = get_attached_file($attachment_id);
if (!$file || !file_exists($file)) return $metadata;
if (!preg_match('/\.(png|jpe?g)$/i', $file)) return $metadata;
$is_ai = get_post_type($attachment_id) === 'mwai_image'
|| preg_match('/^ai_[0-9a-f]{13,}\.\d+\./', basename($file));
if (!$is_ai) return $metadata;
$img = @imagecreatefromstring(file_get_contents($file));
if (!$img) return $metadata;
imagepalettetotruecolor($img);
imagealphablending($img, false);
imagesavealpha($img, true);
$dir = dirname($file);
$webp = $dir . '/' . wp_unique_filename($dir, preg_replace('/\.(png|jpe?g)$/i', '.webp', basename($file)));
$ok = imagewebp($img, $webp, 82);
imagedestroy($img);
if (!$ok) return $metadata;
// Remove the original and any sub-sizes generated before conversion.
if (!empty($metadata['sizes'])) {
foreach ($metadata['sizes'] as $size) {
if (!empty($size['file'])) @unlink($dir . '/' . $size['file']);
}
}
@unlink($file);
update_attached_file($attachment_id, $webp);
wp_update_post([
'ID' => $attachment_id,
'post_mime_type' => 'image/webp',
'guid' => trailingslashit(dirname(get_post_field('guid', $attachment_id))) . basename($webp),
]);
// Regenerate metadata + sub-sizes from the webp original ($busy guards recursion).
$busy = true;
$metadata = wp_generate_attachment_metadata($attachment_id, $webp);
$busy = false;
return $metadata;
}, 10, 2);It’s actually working pretty well. I tested it, and if you want, you can add it to your plugin.
About the file system option, I see there are two categories:
- Uploaded by Users
- Generated by AI
I assume Generated by AI includes both images generated through MCP and images I generate manually using the AI Engine Image Generation tool.
However, Uploaded by Users confuses me a bit. Is this option referring to external users, or am I considered a “user” as well?
I’m an administrator using the tool from the WordPress backend, so I’m not sure what “Users” means in this context. Could you clarify whether it refers to:
- External users uploading files from the frontend, or
- Me, as an administrator, using the AI Engine Image Generation tool in the backend?
Now I have another problem I’m trying to solve.
First, I want to say I’m really sorry for sending so many messages and jumping between different topics.
As I mentioned before, I’m new to AI Engine and I’m exploring a lot of its features right now, so I apologize for constantly bothering you with these questions and issues.
Now, about the problem:
Image Generation can’t generate an image with a transparent background.
I’ve tried every prompt I can think of and multiple models (Google AI Studio and OpenAI API keys with different image models).
Nothing works. Every time I get a fake transparent background. For example:
https://ibb.co/DPPr2C9q
https://ibb.co/Tx0LqHMr
https://ibb.co/TB23tJXcAt first, I thought it might be caused by my new WebP conversion snippet, but I disabled it and the result was exactly the same.
Now I suspect your plugin may be stripping the alpha channel (native transparency). If that’s the case, it would be great if you could preserve it, because it’s extremely useful for creating images without backgrounds, such as 3D elements, icons, logos, and other website assets.
This is the prompt I used in your plugin:
3D roof shingle, ultra-high-quality photorealistic 3D render with realistic textures, subtle lighting, and a soft natural shadow. Isolated on a fully transparent background (alpha channel) with no white, black, gray, gradient, floor, or studio backdrop. The output must contain only the roof shingle and its shadow, with all surrounding pixels fully transparent. Suitable as a premium website asset.I tried this prompt on ChatGPT (use model IMG-GPT2 like your plugin) and its work, it generate 3D with no background.
Please help
Of course you can use the native PHP GD, my plugin Perfect Images (https://wordpress.org/plugins/wp-retina-2x/) does it as well (though it doesn’t work the same way for every server out there, sometimes there is no PHP GD neither). But the solution I shared with you allows you to keep the original images (which are sure to work everywhere), while adding a layer of optimization (WebP or AVIF today, or another format in the future). I personally love to think ahead and build for the future, as everything always change. But of course, your solution is totally okay.
About Uploaded by Users, it’s actually when images are uploaded, it’s usually done via the chatbot. If an admin, or you, upload an image (via the chatbot), it also go through this. It’s managed differently because those images are usually temporary (for vision, etc), but some people like to keep those for logging purposes.
About transparent images, It’s not an issue with AI Engine, it’s the kind of details I always look into and that’s unfortunately a limit of AI modelsβ¦ even the old image models from OpenAI (GPT Image 1.5) uses to support background set to transparent in their API (the docs), but the latest model (GPT Image 2.0) doesn’t support it. ChatGPT is another solution, they might be using an old model (or a new version not released in the API yet).
Unfortunately, as of today (July 9th, just in case), I don’t recommend you to try to generate transparent images with AI. Even though technically you can always find a way (like ask the AI to use a specific color as background and remove that background programmatically – I tried), the results will be way too imperfect. I am sure new image models will come soon, and fix that.
-
This reply was modified 2 weeks, 3 days ago by
Jordy Meow. Reason: ChatGPT does transparent images
I found the problem you right, can do transparent only with gpt image 1.5
work perfect.
the only thing i didn’t understand is Uploaded by Users
So only the chatbot right?
for example:
- If i generate image with AI Engine (not chatbot) it will not getting deleted after an hour?
- If i generate image via MCP it will not getting deleted after an hour?
- If i upload image via MCP it will not getting deleted after an hour?
- If i upload image manually it will not getting deleted after an hour?
But,
If i use the chatbot and upload and image even in the admin, it will delete after an hour? (Uploaded by Users – definition)
i got it right?
Yes, you’ve got it right!
The “Uploaded by Users” expiration only applies to files uploaded into a chatbot (or AI Form). That’s the definition. So:
- β Generate an image via the chatbot β not deleted
- β Generate an image via MCP β not deleted
- β Upload an image via MCP β not deleted
- β Upload an image manually (Media Library, etc) β not deleted
- ποΈ Upload an image into the chatbot (even in admin) β deleted after the hour
Nice, thank you.
You must be logged in to reply to this topic.