Skip to content

Instantly share code, notes, and snippets.

@rexxars
Created September 19, 2012 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rexxars/3748547 to your computer and use it in GitHub Desktop.
Save rexxars/3748547 to your computer and use it in GitHub Desktop.
Imbo try/catch with imageExists
<?php
$fileName = 'someImage.png';
try {
if ($imbo->imageExists($fileName)) {
$photoHash = $imbo->getImageIdentifier($fileName);
} else {
$response = $imbo->addImage($fileName);
$photoHash = $response->getImageIdentifier();
}
echo 'Image available at ' . $imbo->getImageUrl($photoHash)->jpg() . PHP_EOL;
} catch (ImboClient\Exception $e) {
echo 'Failed to add image: ' . $e->getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment