Example #1
0
 /**
  * Adds extra metadata to a File object that used by the form field, such as a thumbnail source.
  *
  * @param File $file
  */
 protected function processFile($file)
 {
     if ($file->ClassName == "Image" || is_subclass_of($file->ClassName, "Image")) {
         if ($thumb = $file->CroppedImage(64, 64)) {
             $file->Thumb = $thumb->getURL();
         }
     } else {
         $file->Thumb = KickAssetUtil::get_icon($file);
     }
     $file->EditLink = Director::absoluteBaseURL() . "/admin/files/select/{$file->ParentID}?edit={$file->ID}";
     $file->RemoveLink = $this->Link('deletefile?id=' . $file->ID);
 }
 /**
  * Adds new properties to the parent (KickAssets) file JSON
  * 
  * @return array
  */
 protected function buildJSON()
 {
     $json = $this->parent->createFileJSON($this->file);
     $json['created'] = $this->file->obj('Created')->FormatFromSettings();
     $json['lastEdited'] = $this->file->obj('LastEdited')->FormatFromSettings();
     $json['url'] = $this->file->getAbsoluteURL();
     $json['size'] = $this->file->getSize();
     $json['folder'] = $this->file->Parent()->Filename;
     if ($this->file instanceof Image) {
         $json['previewImage'] = $this->file->CroppedImage(400, 133)->URL;
         $json['detailImage'] = $this->file->getKickAssetsDetailImage()->URL;
     }
     return $json;
 }