Ejemplo n.º 1
0
 public function onCreateFileImageThumbnailSource(File $file, &$imgPath, $media = null)
 {
     // If we are on a private node, we won't do any remote calls (just as a precaution until
     // we can configure this from config.php for the private nodes)
     if (common_config('site', 'private')) {
         return true;
     }
     // All our remote Oembed images lack a local filename property in the File object
     if ($file->filename !== null) {
         return true;
     }
     try {
         // If we have proper oEmbed data, there should be an entry in the File_oembed
         // and File_thumbnail tables respectively. If not, we're not going to do anything.
         $file_oembed = File_oembed::byFile($file);
         $thumbnail = File_thumbnail::byFile($file);
     } catch (Exception $e) {
         // Not Oembed data, or at least nothing we either can or want to use.
         return true;
     }
     try {
         $this->storeRemoteFileThumbnail($thumbnail);
     } catch (AlreadyFulfilledException $e) {
         // aw yiss!
     }
     $imgPath = $thumbnail->getPath();
     return false;
 }