/** * * draw imaeg input: * @param $setting */ protected function drawImageInput($setting) { $class = UniteFunctionsBiz::getVal($setting, "class"); if (!empty($class)) { $class = "class='{$class}'"; } $settingsID = $setting["id"]; $buttonID = $settingsID . "_button"; $buttonID_remove = $settingsID . "_button_remove"; $spanPreviewID = $buttonID . "_preview"; $width = UniteFunctionsBiz::getVal($setting, "width", 100); $height = UniteFunctionsBiz::getVal($setting, "height", 70); $img = ""; $value = UniteFunctionsBiz::getVal($setting, "value"); $urlImage = ""; if (!empty($value)) { if (is_numeric($value)) { $arrImage = UniteFunctionsWPBiz::getAttachmentImage($value, UniteFunctionsWPBiz::THUMB_MEDIUM); if (!empty($arrImage)) { $urlImage = $arrImage["url"]; $width = $arrImage["width"]; $height = $arrImage["height"]; } } else { //take by image url $urlImage = $value; $imagePath = UniteFunctionsWPBiz::getImageRealPathFromUrl($urlImage); /*if(file_exists($imagePath)){ $filepath = UniteFunctionsWPBiz::getImagePathFromURL($urlImage); $urlImage = UniteBaseClassBiz::getImageUrl($filepath,$width,$height,true); }*/ } } $style = "width:{$width}px;height:{$height}px;"; if (!empty($urlImage)) { $style .= "background-image:url('{$urlImage}');"; } ?> <span id='<?php echo $spanPreviewID; ?> ' class='setting-image-preview' style="<?php echo $style; ?> "><?php echo $img; ?> </span> <input type="hidden" id="<?php echo $setting["id"]; ?> " name="<?php echo $setting["name"]; ?> " data-width="<?php echo $width; ?> " data-height="<?php echo $height; ?> " value="<?php echo $setting["value"]; ?> " /> <input type="button" style="width:auto !important" id="<?php echo $buttonID; ?> " class='button-image-select <?php echo $class; ?> ' value="Choose Image"></input> <input type="button" style="width:auto !important" id="<?php echo $buttonID_remove; ?> " class='button-image-remove <?php echo $class; ?> ' value="Remove Image"></input> <?php }