/** * * init slide by db record */ public function initByData($record) { $this->id = $record["id"]; $this->sliderID = $record["slider_id"]; $this->slideOrder = $record["slide_order"]; $params = $record["params"]; $params = (array) json_decode($params); $layers = $record["layers"]; $layers = (array) json_decode($layers); $layers = UniteFunctionsRev::convertStdClassToArray($layers); $imageID = UniteFunctionsRev::getVal($params, "image_id"); //get image url and thumb url if (!empty($imageID)) { $this->imageID = $imageID; $imageUrl = UniteFunctionsWPRev::getUrlAttachmentImage($imageID); if (empty($imageUrl)) { $imageUrl = UniteFunctionsRev::getVal($params, "image"); } $this->imageThumb = UniteFunctionsWPRev::getUrlAttachmentImage($imageID, UniteFunctionsWPRev::THUMB_MEDIUM); } else { $imageUrl = UniteFunctionsRev::getVal($params, "image"); } //set image path, file and url $this->imageUrl = $imageUrl; $this->imageFilepath = UniteFunctionsWPRev::getImagePathFromURL($this->imageUrl); $realPath = UniteFunctionsWPRev::getPathContent() . $this->imageFilepath; if (file_exists($realPath) == false || is_file($realPath) == false) { $this->imageFilepath = ""; } $this->imageFilename = basename($this->imageUrl); $this->params = $params; $this->arrLayers = $layers; }
/** * * get thumb url */ public function getUrlImageThumb() { //get image url by thumb if (!empty($this->imageID)) { $urlImage = UniteFunctionsWPRev::getUrlAttachmentImage($this->imageID, UniteFunctionsWPRev::THUMB_MEDIUM); } else { //get from cache if (!empty($this->imageFilepath)) { $urlImage = UniteBaseClassRev::getImageUrl($this->imageFilepath, 200, 100, true); } else { $urlImage = $this->imageUrl; } } if (empty($urlImage)) { $urlImage = $this->imageUrl; } return $urlImage; }