fillFromConfig([ 'minWidth', 'aspectRatio' ]); /* if ($this->formField->disabled) { $this->previewMode = true; } //$this->getConfigFormWidget(); */ } /** * @inheritDoc */ public function render() { $this->prepareVars(); return $this->makePartial('responsiveimage'); } /** * Prepares the view data */ protected function prepareVars() { $this->vars['aspectRatio'] = $this->aspectRatio ? str_replace('"', "'", json_encode(explode(' / ', $this->aspectRatio))) : 'null'; $this->vars['minWidth'] = $this->minWidth ?: '0'; $this->vars['name'] = $this->formField->getName(); $this->vars['value'] = $this->getLoadValue() ?: 'null'; $this->vars['meta'] = $this->getLoadValue() ? str_replace('"', "'", json_encode(app(UploadStorage::class)->getFileData($this->getLoadValue()))) : 'null'; $this->vars['model'] = $this->model; } /** * @inheritDoc */ protected function loadAssets() { $this->addCss('css/responsiveimage.build.css', 'core'); $this->addJs('js/responsiveimage.build.js', 'core'); } /** * @inheritDoc */ public function getSaveValue($value) { return $value; } /** * Upload handler for the server-side processing of uploaded files */ public function onUpload() { if (!Input::hasFile('file_data')) { throw new ApplicationException('File missing from request'); } $data = json_decode(Input::get('extraData'), true); $uploadedFile = Input::file('file_data'); if (!$uploadedFile->isValid()) { throw new ApplicationException('File is not valid'); } $attachment = app(UploadStorage::class)->storeFileFromUpload($uploadedFile, $data); return Response::make($attachment->id); } public function onDelete() { app(UploadStorage::class)->removeAttachment(Input::get('file_id')); } }