Browse Source

Add logs & cloudinary in admin

master
Clement Desmidt 2 years ago
parent
commit
e534ffe8dd
1 changed files with 13 additions and 4 deletions
  1. +13
    -4
      cloudinary.php

+ 13
- 4
cloudinary.php View File

@@ -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