/** * @param File $file */ protected function process($file) { if (!($imageInfo = @getimagesize($file->getUri()))) { throw new ImageFileException('The uploaded file is not an image, or the file was not readable.'); } if (!in_array($imageInfo[2], $this->allowedImageTypes)) { throw new ImageFileException('The image type you uploaded is not allowed. Allowed image types are: ' . implode(', ', $this->{$allowedImageTypes}) . '.'); } $file->setWidth($imageInfo[0]); $file->setHeight($imageInfo[1]); $file->setType($imageInfo[2]); }
/** * 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); }