✅ Add logs & cloudinary in admin
This commit is contained in:
parent
fcfb0bde14
commit
e534ffe8dd
@ -20,7 +20,7 @@ class CloudinaryPlugin extends Plugin
|
|||||||
*/
|
*/
|
||||||
public function onPluginsInitialized()
|
public function onPluginsInitialized()
|
||||||
{
|
{
|
||||||
if ($this->isAdmin()) {
|
if (!$this->isAdmin()) {
|
||||||
$this->active = false;
|
$this->active = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -43,10 +43,19 @@ class CloudinaryPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
|
|
||||||
$path = $event['image'];
|
$path = $event['image'];
|
||||||
|
try {
|
||||||
|
|
||||||
$cloudinary_image = \Cloudinary\Uploader::upload($path);
|
$cloudinary_image = \Cloudinary\Uploader::upload($path);
|
||||||
|
|
||||||
if (!empty($cloudinary_image)) {
|
if (!empty($cloudinary_image)) {
|
||||||
file_put_contents($path, $cloudinary_image['secure_url']);
|
file_put_contents($path, $cloudinary_image['secure_url']);
|
||||||
}
|
} else {
|
||||||
|
$this->grav['log']->critical(sprintf('%s has failed its upload to Cloudinary', $path));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Cloudinary\Error $e) {
|
||||||
|
$this->grav['log']->critical(sprintf('Cloudinary API error : %s', $e->getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user