/** * Mutator method for the uploadedFile property. * Accepts the following inputs: * - An absolute string url (for fetching remote files). * - An array (data parsed from the $_FILES array), * - A Symfony uploaded file object. * * @param mixed $uploadedFile */ public function setUploadedFile($uploadedFile) { if (!$this->keep_old_files) { $this->clear(); } if ($uploadedFile == STAPLER_NULL) { $this->clearAttributes(); return; } $this->uploadedFile = FileFactory::create($uploadedFile); $this->instanceWrite('file_name', $this->uploadedFile->getFilename()); $this->instanceWrite('file_size', $this->uploadedFile->getSize()); $this->instanceWrite('content_type', $this->uploadedFile->getMimeType()); $this->instanceWrite('updated_at', new DateTime()); $this->queueAllForWrite(); }
/** * Resize an image using the computed settings. * * @param FileInterface $file * @param StyleInterface $style * * @return string */ public function resize(FileInterface $file, StyleInterface $style) { $filePath = $this->randomFilePath($file->getFilename()); list($width, $height, $option) = $this->parseStyleDimensions($style); $method = 'resize' . ucfirst($option); if ($method == 'resizeCustom') { $this->resizeCustom($file, $style->dimensions)->save($filePath, $style->convertOptions); return $filePath; } $image = $this->imagine->open($file->getRealPath()); if ($style->autoOrient) { $image = $this->autoOrient($file->getRealPath(), $image); } $this->{$method}($image, $width, $height)->save($filePath, $style->convertOptions); return $filePath; }