Created
September 19, 2012 08:58
-
-
Save rexxars/3748547 to your computer and use it in GitHub Desktop.
Imbo try/catch with imageExists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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