Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/controllers/DallEFieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function actionGenerateImages()
'message' => "There was an error communicating with the Open AI API.",
])->setStatusCode(500);
}

return $this->asJson([
'result' => 'error',
'message' => $response->error->message ?? "There was an error communicating with the Open AI API.",
Expand Down Expand Up @@ -91,7 +91,7 @@ public function actionGenerateVariants()
'message' => "There was an error communicating with the Open AI API.",
])->setStatusCode(500);
}

return $this->asJson([
'result' => 'error',
'message' => $response->error->message ?? "There was an error communicating with the Open AI API.",
Expand Down Expand Up @@ -141,7 +141,7 @@ public function actionExtendHorizontally()
'message' => "There was an error communicating with the Open AI API.",
])->setStatusCode(500);
}

return $this->asJson([
'result' => 'error',
'message' => $response->error->message ?? "There was an error communicating with the Open AI API.",
Expand Down Expand Up @@ -199,7 +199,7 @@ public function actionRepaint()
'urls' => $urls,
]);

}
}

public function actionUseImage()
{
Expand Down Expand Up @@ -235,7 +235,9 @@ public function actionUseImage()
'assetId' => $asset->id,
'title' => $asset->title,
'siteId' => '1',
'imageUrl' => $asset->getUrl()
'imageUrl' => $asset->getUrl(),
'height' => $asset->getHeight(),
'width' => $asset->getWidth()
]);

}
Expand All @@ -262,7 +264,7 @@ public function actionUseImagePair()
/** @var DallE $dalle */
$dalle = Plugin::$plugin->dalle;
try{
$asset = $dalle->saveImagePairAsAsset($leftUrl, $rightUrl, $folder);
$asset = $dalle->saveImagePairAsAsset($leftUrl, $rightUrl, $folder);
} catch(\Exception $e) {
return $this->asJson([
'result' => 'error',
Expand All @@ -275,7 +277,9 @@ public function actionUseImagePair()
'assetId' => $asset->id,
'title' => $asset->title,
'siteId' => '1',
'imageUrl' => $asset->getUrl()
'imageUrl' => $asset->getUrl(),
'height' => $asset->getHeight(),
'width' => $asset->getWidth()
]);

}
Expand Down
28 changes: 14 additions & 14 deletions src/templates/field/input.twig
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
<div class="spinner hidden"></div>
<div id="dalle-generator-{{ random(10000,99999) }}" class="dalle-generator field" data-fieldid="{{ fieldId }}">
<div>
{{ forms.button({
label: "Generate Image with Dall-E",
class: [
'btn',
'icon',
'add',
'dashed',
'dalle-generate-button',
]
}) }}
{{ forms.button({
label: "Generate Image with Dall-E",
class: [
'btn',
'icon',
'add',
'dashed',
'dalle-generate-button',
]
}) }}
</div>
</div>
</div>
Expand Down Expand Up @@ -85,8 +85,8 @@
} %}

{% js %}
if(!window.dalle){
window.dalle = {};
if(!window.dalle) {
window.dalle = [];
}
window.dalle[{{ fieldId }}] = new {{ jsClass }}({{ jsSettings|json_encode|raw }});
{% endjs %}
window.dalle.push( new {{ jsClass }}({{ jsSettings|json_encode|raw }}) );
{% endjs %}
Loading