✅ 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()
|
||||
{
|
||||
if ($this->isAdmin()) {
|
||||
if (!$this->isAdmin()) {
|
||||
$this->active = false;
|
||||
return;
|
||||
}
|
||||
@ -43,10 +43,19 @@ class CloudinaryPlugin extends Plugin
|
||||
{
|
||||
|
||||
$path = $event['image'];
|
||||
try {
|
||||
|
||||
$cloudinary_image = \Cloudinary\Uploader::upload($path);
|
||||
|
||||
if (!empty($cloudinary_image)) {
|
||||
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