function tagThumbnail($Item = array()) { $bkg = false; $img = ""; $src = $this->attr("src"); $noimg = $this->attr("noimg"); $form = $this->attr("form"); if ($form == "") { $form = $Item["form"]; } $item = $this->attr("item"); if ($item == "") { $item = $Item["id"]; } $show = $this->attr("show"); $class = $this->attr("class"); $style = $this->attr("style"); $width = $this->attr("width"); if ($width == "") { $width = "160px"; } $height = $this->attr("height"); if ($height == "") { $height = "120px"; } $offset = $this->attr("offset"); $contain = $this->attr("contain"); $srcSrc = $src; $srcImg = explode("/", trim($src)); $srcImg = $srcImg[count($srcImg) - 1]; $srcExt = explode(".", strtolower(trim($srcImg))); $srcExt = $srcExt[count($srcExt) - 1]; $exts = array("jpg", "gif", "png", "svg", "pdf"); if (!in_array($srcExt, $exts)) { $src = "/engine/uploads/__system/filetypes/{$srcExt}.png"; $img = "{$srcExt}.png"; $ext = "png"; } if ($form > "" && $item > "") { $Item = fileReadItem($form, $item); } $json = $this->attr('json'); if ($json > "") { $images = json_decode($json, true); } else { if (isset($Item["images"])) { if (is_array($Item["images"])) { $images = $Item["images"]; } else { $images = json_decode($Item["images"], true); } } else { $images = ""; } } if (is_numeric($this->attr("src"))) { $idx = $this->attr("src"); $this->removeAttr("src"); $num = true; } else { $idx = $this->parents("[idx]")->attr("idx"); if ($idx > "" && $src == "") { $num = true; } else { $idx = 0; } } $size = $this->attr("size"); if ($size > "") { $size = explode(";", $size); if (count($size) == 1) { $size[1] = $size[0]; } $width = $size[0]; $height = $size[1]; if (isset($size[2]) && $size[2] == "src") { $bkg = false; } else { $bkg = true; } } if ($offset > "") { $offset = explode(";", $offset); if (count($offset) == 1) { $offset[1] = $offset[0]; } $top = $offset[1]; $left = $offset[0]; } else { $top = "15%"; $left = "50%"; } if (!is_file($_SESSION["app_path"] . $src) && !is_file($_SERVER["DOCUMENT_ROOT"] . $src)) { if (isset($Item["img"]) && !isset($Item["images"]) && isset($Item["%images"]) && !is_file($src)) { $tmpItem = array(); $tmpItem["images"] = $Item["%images"]; $tmpItem["form"] = $Item["%form"]; $tmpItem["id"] = $Item["%id"]; $src = aikiGetItemImg($tmpItem, $idx, $noimg); } else { if ($noimg > "") { $src = $noimg; } else { if ($bkg == true) { $src = "/engine/uploads/__system/image.svg"; $img = "image.svg"; $ext = "svg"; } if ($bkg == false) { $src = "/engine/uploads/__system/image.jpg"; $img = "image.jpg"; $ext = "jpg"; } } } } $img = explode("/", trim($src)); $img = $img[count($img) - 1]; $ext = explode(".", trim($src)); $ext = $ext[count($ext) - 1]; if (is_array($images)) { if (isset($images[$idx])) { $img = $images[$idx]["img"]; } else { $img = ""; } $src = aikiGetItemImg($Item, $idx, $noimg); $this->attr("src", $src); } if ($src == array()) { $src = ""; } if ($img == "" and $bkg == true) { $src = "/engine/uploads/__system/image.svg"; $img = "image.svg"; $ext = "svg"; } if ($src == "" and $bkg == true) { $src = "/engine/uploads/__system/image.svg"; $img = "image.svg"; $ext = "svg"; } else { if ($src == "" and $bkg == false) { $src = "/engine/uploads/__system/image.jpg"; $img = "image.jpg"; $ext = "jpg"; } $img = explode("/", $src); $img = $img[count($img) - 1]; $this->attr("img", $img); $ext = substr($img, -3); } if ($ext !== "svg") { if ($contain == "true") { $thumb = "thumbc"; } else { $thumb = "thumb"; } $src = urldecode($src); if (substr($width, -1) == "%" or substr($height, -1) == "%") { list($w, $h, $t) = getimagesize($_SERVER["DOCUMENT_ROOT"] . $src); $w = ceil($w / 100 * ($width + 0)); $h = ceil($h / 100 * ($height + 0)); $src = "/{$thumb}/{$w}x{$h}/src{$src}"; } else { $w = $width + 0; $h = $height + 0; $src = "/{$thumb}/{$w}x{$h}/src{$src}"; } } if ($bkg == true) { if (!in_array($srcExt, $exts)) { $bSize = "contain"; } else { $bSize = "cover"; } $style .= "width:{$width}; height: {$height}; background: url('{$src}') {$left} {$top} no-repeat; display:inline-block; background-size: {$bSize}; background-clip: content-box;"; $this->attr("src", "/engine/uploads/__system/transparent.png"); $this->attr("width", $width); $this->attr("height", $height); } else { if ($ext !== "svg") { // $src.="&h={$height}&zc=1"; $this->attr("src", $src); } } $this->attr("data-src", $srcSrc); $this->attr("data-ext", $srcExt); $this->attr("class", $class); $this->attr("noimg", $noimg); $this->attr("style", $style); $this->removeAttr('json'); }
function aikiAddItemGal($Item = array(), $Field = "text") { if (isset($Item["images_position"])) { $gallery = '<div data-role="gallery"></div>'; if ($Item["images_position"] == "top") { $Item[$Field] = $gallery . "\r\n" . $Item[$Field]; } if ($Item["images_position"] == "bottom") { $Item[$Field] .= "\r\n" . $gallery; } } if (isset($Item["intext_position"]) && $Item["intext_position"]["pos"] > "") { if ($Item["intext_position"]["width"] > "") { $w = $Item["intext_position"]["width"]; } else { $w = 240; } if ($Item["intext_position"]["height"] > "") { $h = $Item["intext_position"]["height"]; } else { $h = 120; } $pos = $Item["intext_position"]["pos"]; if ($pos == "left") { $margin = "0px 10px 10px 0px"; } else { $margin = "0px 0px 10px 10px"; } $imgsrc = "/thumb/{$w}x{$h}/src" . aikiGetItemImg($Item); $img = "<img src='{$imgsrc}' style='float:{$pos};margin:{$margin}' alt='img' class='img-responsive'>"; $Item["text"] = $img . $Item["text"]; } return $Item; }