public function treeGetChildsByIdAction() { $assets = array(); $asset = Asset::getById($this->_getParam("node")); if ($asset->hasChilds()) { $limit = intval($this->_getParam("limit")); if (!$this->_getParam("limit")) { $limit = 100000000; } $offset = intval($this->_getParam("start")); // get assets $childsList = new Asset_List(); $childsList->setCondition("parentId = ?", $asset->getId()); $childsList->setLimit($limit); $childsList->setOffset($offset); $childsList->setOrderKey("filename"); $childsList->setOrder("asc"); $childs = $childsList->load(); foreach ($childs as $childAsset) { if ($childAsset->isAllowed("list")) { $assets[] = $this->getTreeNodeConfig($childAsset); } } } if ($this->_getParam("limit")) { $this->_helper->json(array("total" => $asset->getChildAmount(), "nodes" => $assets)); } else { $this->_helper->json($assets); } $this->_helper->json(false); }
$allowedThumbs = explode(",", $opts->getOption("thumbnails")); } // get only images $conditions = array("type = 'image'"); if ($opts->getOption("parent")) { $parent = Asset::getById($opts->getOption("parent")); if ($parent instanceof Asset_Folder) { $conditions[] = "path LIKE '" . $parent->getFullPath() . "/%'"; } else { echo $opts->getOption("parent") . " is not a valid asset folder ID!\n"; exit; } } $list = new Asset_List(); $list->setCondition(implode(" AND ", $conditions)); $total = $list->getTotalCount(); $perLoop = 10; for ($i = 0; $i < ceil($total / $perLoop); $i++) { $list->setLimit($perLoop); $list->setOffset($i * $perLoop); $images = $list->load(); foreach ($images as $image) { foreach ($thumbnails as $thumbnail) { if (empty($allowedThumbs) || in_array($thumbnail, $allowedThumbs)) { echo "generating thumbnail for image: " . $image->getFullpath() . " | " . $image->getId() . " | Thumbnail: " . $thumbnail . " : " . formatBytes(memory_get_usage()) . " \n"; $image->getThumbnail($thumbnail); } } } Pimcore::collectGarbage(); }