private function getItems() { $res = []; $images = Files::getAttachedFiles(\app\models\Resources::$tableId, $this->_config['album']); foreach ($images as $im) { $cfg['content'] = '<img src="' . $im->url . '"/>'; if ($this->_config['showHeader']) { $cfg['caption'] = str_replace('{*title*}', $im->title, $this->_config['headerTemplate']); } $res[] = $cfg; } return $res; }
public function run($table, $id) { /* $onlyExtensions = array_map( function ($ext) { return '*.'.$ext; }, Yii::$app->controller->module->imageAllowExtensions ); $filesPath = FileHelper::findFiles(Yii::$app->controller->module->getSaveDir(), [ 'recursive' => true, 'only' => $onlyExtensions ]);*/ $files = Files::getAttachedFiles($table, $id); $res = []; foreach ($files as $file) { $file->attachBehavior('image', ['class' => ImageBehavior::className()]); $res[] = ['thumb' => $file->thumbnailUrl, 'image' => $file->url, 'title' => $file->title]; } return $res; }