static function getListWidget($postDBRow) { $html = NULL; // case when list_item.item_id is not Tnull but post.id is NULL if (empty($postDBRow["id"]) && !empty($postDBRow["item_id"])) { $template = '/fragments/widget/lists/deleted-item.tmpl'; $view = new \stdClass(); $view->id = $postDBRow["item_id"]; $view->itemId = PseudoId::encode($postDBRow["item_id"]); $html = Template::render($template, $view); return $html; } $voptions = array("group" => true); $view = self::createPostView($postDBRow, $voptions); if ($view->hasImage) { $template = '/fragments/widget/lists/image.tmpl'; //Add thumbnail width and height $td = Util::foldX($view->width, $view->height, 190); $view->twidth = $td["width"]; $view->theight = $td["height"]; } else { $template = '/fragments/widget/lists/text.tmpl'; } $html = Template::render($template, $view); return $html; }
public function computeHW($sBlobData) { //compute height and width using GD2 functions // GD2 functions are in global namespace $oSourceImage = \imagecreatefromstring($sBlobData); if ($oSourceImage == false) { //unrecoverable error $errorMsg = "GD2 : Not able to create source image from supplied file data "; trigger_error($errorMsg, E_USER_ERROR); } //original width and height $this->mediaData->width = imagesx($oSourceImage); $this->mediaData->height = imagesy($oSourceImage); //@todo thumbail width from config $td = Util::foldX($this->mediaData->width, $this->mediaData->height, 190); $oDestinationImage = \imagecreatetruecolor($td["width"], $td["height"]); // resample the image - do not use resized if you need quality \imagecopyresampled($oDestinationImage, $oSourceImage, 0, 0, 0, 0, $td["width"], $td["height"], $this->mediaData->width, $this->mediaData->height); ob_start(); //default quality is 75. \imagejpeg($oDestinationImage, NULL, 100); $tBlobData = ob_get_contents(); ob_end_clean(); // Free up memory \imagedestroy($oDestinationImage); return $tBlobData; }