WordPress\AiClient\Providers\OpenAiCompatibleImplementation
AbstractOpenAiCompatibleImageGenerationModel::prepareSizeParam
Prepares the size parameter for the API request.
Метод класса: AbstractOpenAiCompatibleImageGenerationModel{}
Хуков нет.
Возвращает
string. The prepared size parameter.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->prepareSizeParam( ?MediaOrientationEnum $orientation, ?string $aspectRatio ): string;
- ?MediaOrientationEnum $orientation(обязательный)
- .
- ?string $aspectRatio(обязательный)
- .
Список изменений
| С версии 0.1.0 | Введена. |
Код AbstractOpenAiCompatibleImageGenerationModel::prepareSizeParam() AbstractOpenAiCompatibleImageGenerationModel::prepareSizeParam WP 7.1.2
protected function prepareSizeParam(?MediaOrientationEnum $orientation, ?string $aspectRatio): string
{
// Use aspect ratio if set, as it is more specific.
if ($aspectRatio !== null) {
switch ($aspectRatio) {
case '1:1':
return '1024x1024';
case '3:2':
return '1536x1024';
case '7:4':
return '1792x1024';
case '2:3':
return '1024x1536';
case '4:7':
return '1024x1792';
default:
throw new InvalidArgumentException('The aspect ratio "' . $aspectRatio . '" is not supported.');
}
}
// This should always have a value, as the method is only called if at least one or the other is set.
if ($orientation !== null) {
if ($orientation->isLandscape()) {
return '1536x1024';
}
if ($orientation->isPortrait()) {
return '1024x1536';
}
}
return '1024x1024';
}