/** * Returns an array with the size of the Image thumbnail * * Uses the same indices for width (0), height (1), * and the height/width text string (3) as getimagesize(). * @return array The Image thumbnail size */ function getSizeArrayThumbnail() { $width_max = \Cx\Core\ImageType\Controller\ImageType::getWidthThumbnail($this->imagetype_key); $height_max = \Cx\Core\ImageType\Controller\ImageType::getHeightThumbnail($this->imagetype_key); return self::getScaledSize($this->getSizeArray(), $width_max, $height_max); }
/** * Returns HTML code for an image element with form * elements for uploading an image file. * * Uses the $id parameter as prefix for both the name and id attributes * of all HTML elements. The names and respective suffixes are: * - id+'_img' for the name and id of the <img> tag * - id+'_src' for the name and id of the hidden <input> tag for the image path * - id+'_type' for the name and id of the hidden <input> tag or <select> * menu for the Imagetype * - id+'_width' for the name and id of the hidden <input> tag for the width * - id+'_height' for the name and id of the hidden <input> tag for the height * - id+'_file' for the name and id of the file upload element * The file upload element will provide the new image chosen by the user * when the form is posted, while the hidden fields represent the previous * state when the page was generated. * The $path_default will replace the path of the image shown if that is * empty, but the path posted back will remain empty so the default image * is not accidentally stored. * If the optional $imagetype_key is empty or not an array, * no image type can be selected. If it's false, the image type field is * omitted. If it's empty but not false, the current * Image's type is used. If it's a string, the type is set to * that value, overriding the Image's current type. If it's an array, * the Image type can be selected from its values, and the current Image's * key is preselected. The array keys *SHOULD* contain the Imagetype key, * its values the Imagetype names in the current language. * See {@see Image::updatePostImages()} and {@see Image::uploadAndStore()} * for more information and examples. * @param Image $objImage The image object * @param string $id The base name for the elements IDs * @param mixed $imagetype_key The optional Image type key or * Imagetype array. Defaults to the * empty string * @param string $path_default The optional path of a default image. * Defaults to the empty string * @param boolean $replace_only If true, the image cannot be deleted, * but there's always a file upload input * to replace the current image. * Defaults to false * @return string The HTML code for all the elements */ static function getImageChooserUpload($objImage, $id, $imagetype_key = '', $path_default = '', $replace_only = false) { global $_CORELANG; JS::registerCode(self::getJavascript_Image($path_default)); if (empty($objImage)) { $objImage = new Image(0); } $path = $objImage->getPath(); $path_thumb = $path_default; $width = $height = null; if ($path) { $path_thumb = $path ? Image::getThumbnailPath($path) : ''; list($width, $height) = $objImage->getSizeArrayThumbnail(); } else { if (empty($width) && empty($height)) { $key = is_array($imagetype_key) ? '' : $imagetype_key; $width = \Cx\Core\ImageType\Controller\ImageType::getWidthThumbnail($key); $height = \Cx\Core\ImageType\Controller\ImageType::getHeightThumbnail($key); } } // $arrImagetypeName = \Cx\Core\ImageType\Controller\ImageType::getNameArray(); // if ($imagetype_key === false) // $imagetype_key = $objImage->getImagetypeKey(); $path_preview = (defined('BACKEND_LANG_ID') ? '../' : '') . $path_thumb; return self::getImageByPath($path_preview, 'style="width: ' . $width . 'px; height: ' . $height . 'px;"' . ' title="' . $_CORELANG['TXT_CORE_HTML_IMAGE_PREVIEW'] . '"' . ' alt="' . $_CORELANG['TXT_CORE_HTML_IMAGE_PREVIEW'] . '"' . ' id=' . $id . '_img') . "\n" . ($path ? ($replace_only ? '' : self::getClearImageCode($id)) . self::getHidden($id . '_src', $objImage->getPath(), '') : '') . '<br />' . '<br />' . ($path ? sprintf($_CORELANG['TXT_CORE_HTML_IMAGE_CURRENT'], basename($objImage->getPath())) . '<br />' : '') . \Cx\Core\ImageType\Controller\ImageType::getMenu($id, $objImage->getImagetypeKey(), $imagetype_key) . self::getHidden($id . '_id', $objImage->getId(), '') . self::getHidden($id . '_ord', $objImage->getOrd(), '') . '<br />' . self::getInputFileupload($id, '', Image::MAXIMUM_UPLOAD_FILE_SIZE, Filetype::MIMETYPE_IMAGES_WEB, '', $replace_only || empty($path)); }