GenerativeAiResult::toImageFile(): WordPressAiClientFilesDTOFile

In this article

Converts the first candidate to an image file.

Return

WordPressAiClientFilesDTOFile The image file.

Source

public function toImageFile(): File
{
    $file = $this->toFile();
    if (!$file->isImage()) {
        throw new RuntimeException(sprintf('File is not an image. MIME type: %s', $file->getMimeType()));
    }
    return $file;
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.