Browse Source

Add logs & cloudinary in admin

master
Clement Desmidt 4 years ago
parent
commit
e534ffe8dd
  1. 17
      cloudinary.php

17
cloudinary.php

@ -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'];
$cloudinary_image = \Cloudinary\Uploader::upload($path);
try {
if (!empty($cloudinary_image)) {
file_put_contents($path, $cloudinary_image['secure_url']);
$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…
Cancel
Save