Add an image field, required for WordPress posts
Posts get a nullable image_url. WordPressPublisher now downloads it and uploads it to WordPress's media endpoint before creating the post, setting it as featured_media — and rejects publishing (without touching status) if a blog post has no image set, mirroring the existing title requirement. Every other network treats it as optional. Not enforced at save time, same as title — you can still draft an incomplete WordPress post, it just can't be published until an image is set. Exposed through the UI form (with a thumbnail/""missing"" indicator in the table), the JSON API, and the Python CLI wrapper. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -142,3 +142,22 @@ test('it includes published_url in the post response', function () {
|
||||
|
||||
$response->assertOk()->assertJsonPath('data.published_url', 'https://example.com/my-post');
|
||||
});
|
||||
|
||||
test('image_url can be set on create and update', function () {
|
||||
$site = Site::factory()->create();
|
||||
|
||||
$response = $this->postJson('/api/posts', [
|
||||
'site_id' => $site->id,
|
||||
'type' => 'blog',
|
||||
'body' => 'content',
|
||||
'image_url' => 'https://example.com/photo.jpg',
|
||||
]);
|
||||
|
||||
$response->assertCreated()->assertJsonPath('data.image_url', 'https://example.com/photo.jpg');
|
||||
|
||||
$post = Post::latest('id')->first();
|
||||
|
||||
$this->patchJson("/api/posts/{$post->id}", ['image_url' => 'https://example.com/new-photo.jpg'])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.image_url', 'https://example.com/new-photo.jpg');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user