public function getFolderContentPreviewAction()
{
$folder = Asset::getById($this->getParam("id"));
$start = 0;
$limit = 10;
if ($this->getParam("limit")) {
$limit = $this->getParam("limit");
}
if ($this->getParam("start")) {
$start = $this->getParam("start");
}
$condition = "path LIKE '" . ($folder->getRealFullPath() == "/" ? "/%'" : $folder->getRealFullPath() . "/%'") . " AND type != 'folder'";
$list = Asset::getList(["condition" => $condition, "limit" => $limit, "offset" => $start, "orderKey" => "filename", "order" => "asc"]);
$assets = [];
foreach ($list as $asset) {
$thumbnailMethod = "";
if ($asset instanceof Asset\Image) {
$thumbnailMethod = "getThumbnail";
} elseif ($asset instanceof Asset\Video && \Pimcore\Video::isAvailable()) {
$thumbnailMethod = "getImageThumbnail";
} elseif ($asset instanceof Asset\Document && \Pimcore\Document::isAvailable()) {
$thumbnailMethod = "getImageThumbnail";
}
if (!empty($thumbnailMethod)) {
$filenameDisplay = $asset->getFilename();
if (strlen($filenameDisplay) > 32) {
$filenameDisplay = substr($filenameDisplay, 0, 25) . "..." . \Pimcore\File::getFileExtension($filenameDisplay);
}
$assets[] = ["id" => $asset->getId(), "type" => $asset->getType(), "filename" => $asset->getFilename(), "filenameDisplay" => $filenameDisplay, "url" => "/admin/asset/get-" . $asset->getType() . "-thumbnail/id/" . $asset->getId() . "/treepreview/true", "idPath" => $data["idPath"] = Element\Service::getIdPath($asset)];
}
}
$this->_helper->json(["assets" => $assets, "success" => true, "total" => $list->getTotalCount()]);
}