fillFromConfig([ 'mode', 'prompt', 'imageWidth', 'imageHeight' ]); if ($this->formField->disabled) { $this->previewMode = true; } } /** * @inheritDoc */ public function render() { $this->prepareVars(); return $this->makePartial('mediafinder'); } /** * Prepares the list data */ public function prepareVars() { $value = $this->getLoadValue(); $this->vars['value'] = $value; $this->vars['imageUrl'] = $value ? MediaLibrary::url($value) : ''; $this->vars['field'] = $this->formField; $this->vars['prompt'] = str_replace('%s', '', trans($this->prompt)); $this->vars['mode'] = $this->mode; $this->vars['imageWidth'] = $this->imageWidth; $this->vars['imageHeight'] = $this->imageHeight; } /** * @inheritDoc */ public function getSaveValue($value) { if ($this->formField->disabled || $this->formField->hidden) { return FormField::NO_SAVE_DATA; } return $value; } /** * @inheritDoc */ protected function loadAssets() { $this->addJs('js/mediafinder.js', 'core'); $this->addCss('css/mediafinder.css', 'core'); } }