/** * 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 some metadata to a {@link File} object that is used by the view. This function * allows us to avoid having to use a decorator on the {@link File} class. * * @param File * @return array */ protected function getFields(File $f) { if ($f instanceof Folder) { return array('Link' => $this->Link($this->getBrowseAction() . '/' . $f->ID), 'Item' => $f); } $image = $f instanceof Image; $tooltipurl = ""; if ($image) { if ($f->getHeight() > 64 || $f->getWidth() > 64) { if ($f->getOrientation() == Image::ORIENTATION_SQUARE || $f->getOrientation() == Image::ORIENTATION_LANDSCAPE) { $tooltipurl = $f->getWidth() > self::$tooltip_size ? $f->SetWidth(self::$tooltip_size)->getURL() : $f->getURL(); } else { $tooltipurl = $f->getHeight() > self::$tooltip_size ? $f->setHeight(self::$tooltip_size)->getURL() : $f->getURL(); } } } return array('Link' => '', 'Item' => $f, 'IconURL' => $image ? ($i = $f->SetHeight(64)) ? $i->getURL() : KickAssetUtil::get_icon($f) : KickAssetUtil::get_icon($f), 'Image' => $image, 'TooltipURL' => $tooltipurl); }