本文整理汇总了PHP中Image::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::getPath方法的具体用法?PHP Image::getPath怎么用?PHP Image::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::getPath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Generate the content element
*/
protected function compile()
{
$objFile = new \File($this->singleSRC);
if ($this->linkTitle == '') {
$this->linkTitle = \StringUtil::specialchars($objFile->basename);
}
$strHref = \Environment::get('request');
// Remove an existing file parameter (see #5683)
if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
$strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
}
$strHref .= (strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objFile->value);
$this->Template->link = $this->linkTitle;
$this->Template->title = \StringUtil::specialchars($this->titleText ?: sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename));
$this->Template->href = $strHref;
$this->Template->filesize = $this->getReadableSize($objFile->filesize, 1);
$this->Template->icon = \Image::getPath($objFile->icon);
$this->Template->mime = $objFile->mime;
$this->Template->extension = $objFile->extension;
$this->Template->path = $objFile->dirname;
}
示例2: resolveImageVersionPath
/**
* Returns the path to a specific image version.
* @param Image $image the image model.
* @param string $version the image version.
* @return string the path.
*/
protected function resolveImageVersionPath($image, $version)
{
return $this->getVersionPath($version, true) . $image->getPath();
}
示例3: tag
public function tag(Image $img)
{
return "<img src = \"{$img->getPath()}\" alt=\"\" width=\"{$img->getWidth()}\" height=\"{$img->getHeight()}\" />";
}
示例4: generate
/**
* Generate the widget and return it as string
*
* @return string
*/
public function generate()
{
$arrSet = array();
$arrValues = array();
$blnHasOrder = $this->orderField != '' && is_array($this->{$this->orderField});
if (!empty($this->varValue)) {
$objFiles = \FilesModel::findMultipleByUuids((array) $this->varValue);
$allowedDownload = \StringUtil::trimsplit(',', strtolower(\Config::get('allowedDownload')));
if ($objFiles !== null) {
while ($objFiles->next()) {
// File system and database seem not in sync
if (!file_exists(TL_ROOT . '/' . $objFiles->path)) {
continue;
}
$arrSet[$objFiles->id] = $objFiles->uuid;
// Show files and folders
if (!$this->isGallery && !$this->isDownloads) {
if ($objFiles->type == 'folder') {
$arrValues[$objFiles->uuid] = \Image::getHtml('folderC.svg') . ' ' . $objFiles->path;
} else {
$objFile = new \File($objFiles->path);
$strInfo = $objFiles->path . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isImage ? ', ' . $objFile->width . 'x' . $objFile->height . ' px' : '') . ')</span>';
if ($objFile->isImage) {
$image = \Image::getPath('placeholder.svg');
if (($objFile->isSvgImage || $objFile->height <= \Config::get('gdMaxImgHeight') && $objFile->width <= \Config::get('gdMaxImgWidth')) && $objFile->viewWidth && $objFile->viewHeight) {
$image = \Image::get($objFiles->path, 80, 60, 'center_center');
}
$arrValues[$objFiles->uuid] = \Image::getHtml($image, '', 'class="gimage" title="' . \StringUtil::specialchars($strInfo) . '"');
} else {
$arrValues[$objFiles->uuid] = \Image::getHtml($objFile->icon) . ' ' . $strInfo;
}
}
} else {
if ($objFiles->type == 'folder') {
$objSubfiles = \FilesModel::findByPid($objFiles->uuid);
if ($objSubfiles === null) {
continue;
}
while ($objSubfiles->next()) {
// Skip subfolders
if ($objSubfiles->type == 'folder') {
continue;
}
$objFile = new \File($objSubfiles->path);
$strInfo = '<span class="dirname">' . dirname($objSubfiles->path) . '/</span>' . $objFile->basename . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isImage ? ', ' . $objFile->width . 'x' . $objFile->height . ' px' : '') . ')</span>';
if ($this->isGallery) {
// Only show images
if ($objFile->isImage) {
$image = \Image::getPath('placeholder.svg');
if (($objFile->isSvgImage || $objFile->height <= \Config::get('gdMaxImgHeight') && $objFile->width <= \Config::get('gdMaxImgWidth')) && $objFile->viewWidth && $objFile->viewHeight) {
$image = \Image::get($objSubfiles->path, 80, 60, 'center_center');
}
$arrValues[$objSubfiles->uuid] = \Image::getHtml($image, '', 'class="gimage" title="' . \StringUtil::specialchars($strInfo) . '"');
}
} else {
// Only show allowed download types
if (in_array($objFile->extension, $allowedDownload) && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
$arrValues[$objSubfiles->uuid] = \Image::getHtml($objFile->icon) . ' ' . $strInfo;
}
}
}
} else {
$objFile = new \File($objFiles->path);
$strInfo = '<span class="dirname">' . dirname($objFiles->path) . '/</span>' . $objFile->basename . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isImage ? ', ' . $objFile->width . 'x' . $objFile->height . ' px' : '') . ')</span>';
if ($this->isGallery) {
// Only show images
if ($objFile->isImage) {
$image = \Image::getPath('placeholder.svg');
if (($objFile->isSvgImage || $objFile->height <= \Config::get('gdMaxImgHeight') && $objFile->width <= \Config::get('gdMaxImgWidth')) && $objFile->viewWidth && $objFile->viewHeight) {
$image = \Image::get($objFiles->path, 80, 60, 'center_center');
}
$arrValues[$objFiles->uuid] = \Image::getHtml($image, '', 'class="gimage removable" title="' . \StringUtil::specialchars($strInfo) . '"');
}
} else {
// Only show allowed download types
if (in_array($objFile->extension, $allowedDownload) && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
$arrValues[$objFiles->uuid] = \Image::getHtml($objFile->icon) . ' ' . $strInfo;
}
}
}
}
}
}
// Apply a custom sort order
if ($blnHasOrder) {
$arrNew = array();
foreach ((array) $this->{$this->orderField} as $i) {
if (isset($arrValues[$i])) {
$arrNew[$i] = $arrValues[$i];
unset($arrValues[$i]);
}
}
if (!empty($arrValues)) {
foreach ($arrValues as $k => $v) {
$arrNew[$k] = $v;
//.........这里部分代码省略.........
示例5: findListGoods
public function findListGoods()
{
$_priceSQL = '';
$_brandSQL = '';
$_attrSQL = '';
if ($this->_R['price']) {
$_left = substr($this->_R['price'], 0, strpos($this->_R['price'], ','));
$_right = substr($this->_R['price'], strpos($this->_R['price'], ',') + 1);
$_priceSQL = "AND price_sale BETWEEN {$_left} AND {$_right}";
}
if ($this->_R['brand']) {
if ($this->_R['brand'] == 'other') {
$_brand = 0;
} else {
$_brand = $this->_R['brand'];
}
$_brandSQL = "AND brand='{$_brand}'";
}
if ($this->_R['attr']) {
$_attr = explode(':', $this->_R['attr']);
$_attrSQL = "AND attr LIKE '%{$_attr['0']}%{$_attr['1']}%'";
}
$_getNavId = $this->getNavId();
$this->_tables = array(DB_PREFIX . 'goods a');
$_allGoods = parent::select(array('id', 'nav', 'name', 'price_sale', 'price_market', 'thumbnail', 'thumbnail2', 'unit', 'sales', '(SELECT COUNT(*) FROM mall_commend b WHERE flag=0 AND b.goods_id=a.id ) AS count'), array('limit' => $this->_limit, 'where' => array("nav in ({$_getNavId}) AND is_up=1 {$_priceSQL} {$_brandSQL} {$_attrSQL}"), 'order' => 'date DESC'));
$this->_tables = array(DB_PREFIX . 'goods');
foreach ($_allGoods as $_value) {
if (Validate::isNullString($_value->thumbnail2)) {
$_img = new Image($_value->thumbnail);
$_img->thumb(220, 220);
$_img->out('220x220');
$_value->thumbnail2 = $_img->getPath();
parent::update(array("id='{$_value->id}'"), array('thumbnail2' => $_img->getPath()));
}
}
return $_allGoods;
}
示例6: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$files = array();
$auxDate = array();
$objFiles = $this->objFiles;
$allowedDownload = \StringUtil::trimsplit(',', strtolower(\Config::get('allowedDownload')));
// Get all files
while ($objFiles->next()) {
// Continue if the files has been processed or does not exist
if (isset($files[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
continue;
}
// Single files
if ($objFiles->type == 'file') {
$objFile = new \File($objFiles->path);
if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
continue;
}
$arrMeta = $this->getMetaData($objFiles->meta, $objPage->language);
if (empty($arrMeta)) {
if ($this->metaIgnore) {
continue;
} elseif ($objPage->rootFallbackLanguage !== null) {
$arrMeta = $this->getMetaData($objFiles->meta, $objPage->rootFallbackLanguage);
}
}
// Use the file name as title if none is given
if ($arrMeta['title'] == '') {
$arrMeta['title'] = \StringUtil::specialchars($objFile->basename);
}
$strHref = \Environment::get('request');
// Remove an existing file parameter (see #5683)
if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
$strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
}
$strHref .= (strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objFiles->path);
// Add the image
$files[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'title' => \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename)), 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => $this->getReadableSize($objFile->filesize, 1), 'icon' => \Image::getPath($objFile->icon), 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
$auxDate[] = $objFile->mtime;
} else {
$objSubfiles = \FilesModel::findByPid($objFiles->uuid);
if ($objSubfiles === null) {
continue;
}
while ($objSubfiles->next()) {
// Skip subfolders
if ($objSubfiles->type == 'folder') {
continue;
}
$objFile = new \File($objSubfiles->path);
if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
continue;
}
$arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->language);
if (empty($arrMeta)) {
if ($this->metaIgnore) {
continue;
} elseif ($objPage->rootFallbackLanguage !== null) {
$arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->rootFallbackLanguage);
}
}
// Use the file name as title if none is given
if ($arrMeta['title'] == '') {
$arrMeta['title'] = \StringUtil::specialchars($objFile->basename);
}
$strHref = \Environment::get('request');
// Remove an existing file parameter (see #5683)
if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
$strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
}
$strHref .= (strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objSubfiles->path);
// Add the image
$files[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'title' => \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename)), 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => $this->getReadableSize($objFile->filesize, 1), 'icon' => \Image::getPath($objFile->icon), 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
$auxDate[] = $objFile->mtime;
}
}
}
// Sort array
switch ($this->sortBy) {
default:
case 'name_asc':
uksort($files, 'basename_natcasecmp');
break;
case 'name_desc':
uksort($files, 'basename_natcasercmp');
break;
case 'date_asc':
array_multisort($files, SORT_NUMERIC, $auxDate, SORT_ASC);
break;
case 'date_desc':
array_multisort($files, SORT_NUMERIC, $auxDate, SORT_DESC);
break;
// Deprecated since Contao 4.0, to be removed in Contao 5.0
// Deprecated since Contao 4.0, to be removed in Contao 5.0
case 'meta':
//.........这里部分代码省略.........
示例7: header
header("Location: " . $_SERVER["REQUEST_URI"]);
//Redirect to prevent form resubmission
}
//Process the upload profile image form
if (isset($_POST["upload_profile_pic"])) {
if (isset($_FILES['default-image'])) {
$Image = new Image($Database);
$Image->uploadTo = $baseDir . 'images/profiles/';
$uploadedImage = $Image->upload($_FILES['default-image']);
if ($uploadedImage) {
$Image->newWidth = 50;
$Image->newHeight = 50;
$path = $Image->resize();
try {
$Image->setPath($path, $url, $baseDir);
$thumbnailUrl = $Image->getPath();
$Statement = $Database->prepare("UPDATE users SET thumbnail = ? WHERE id = ?");
$Statement->execute(array($thumbnailUrl, $user["id"]));
header("Location: " . $_SERVER["REQUEST_URI"]);
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
}
//Process the message reply form
if (isset($_POST["send_reply" . $messageCount])) {
$Message = new Message($user["id"], $Database);
//Instantiate the message class
try {
$Message->setReciever($_POST["sid" . $messageCount]);
示例8: getClearImageCode
static function getClearImageCode($id)
{
global $_CORELANG;
$objImage = new Image();
$objImage->setPath(self::ICON_FUNCTION_CLEAR_IMAGE);
// Fix the image paths in case we're not in the backend
if (!defined('BACKEND_LANG_ID')) {
$objImage->setPath(ASCMS_PATH_OFFSET . ASCMS_BACKEND_PATH . '/' . $objImage->getPath());
}
$objImage->setWidth(16);
$objImage->setHeight(16);
return '<a id="' . $id . '_clear" href="javascript:void(0);"' . ' onclick="clearImage(\'' . $id . '\');">' . self::getImageOriginal($objImage, 'border="0" alt="' . $_CORELANG['TXT_CORE_HTML_DELETE_IMAGE'] . '" title="' . $_CORELANG['TXT_CORE_HTML_DELETE_IMAGE'] . '"') . '</a>';
}
示例9: getListGoods
public function getListGoods()
{
$id = $this->getId();
$priceSql = '';
$attrSql = '';
$brandSql = '';
$attrSql = '';
if ($this->R['price']) {
$priceSql = 'AND price_sale BETWEEN ' . str_replace(',', ' AND ', $this->R['price']);
}
if ($this->R['brand']) {
$brandSql = ' AND brand=' . $this->R['brand'];
}
if ($this->R['attr']) {
// $attrSql =str_replace('-', '%', $this->R['attr']);
// $attrSql =" AND attr LIKE '%$attrSql%'";
$temp = explode('-', $this->R['attr']);
foreach ($temp as $key => $value) {
$attrSql .= " AND attr LIKE '%{$value}%' ";
}
}
$this->tables = array(DB_FREFIX . 'goods g');
$allGoods = parent::select(array('id', 'name', 'thumb', 'price_sale', 'price_market', 'unit', 'sale_count', 'thumb_small', 'nav', '(SELECT COUNT(*) FROM mall_commend c WHERE c.goods_id=g.id) AS count'), array('where' => array("nav IN ('{$id}') {$priceSql} {$brandSql} {$attrSql}", 'is_up=1'), 'order' => 'date DESC', 'limit' => $this->limit));
$this->tables = array(DB_FREFIX . 'goods');
foreach ($allGoods as $value) {
if (Validate::isNullStr($value->thumb_small)) {
$img = new Image($value->thumb);
$img->thumb(220, 220);
$img->outImage('220x220');
parent::update(array("id='{$value->id}'"), array('thumb_small' => $img->getPath()));
$value->thumb_small = $img->getPath();
}
}
return $allGoods;
}
示例10: smarty_function_image
function smarty_function_image($params, &$smarty) {
echo $params['name'];
$image = new Image($params['name'], $params['alt']);
return '<img src="'.$image->getPath($params['height'], $params['width']).'" alt="'.$params['alt'].'" />';
}
示例11: addEnclosuresToTemplate
/**
* Add enclosures to a template
*
* @param object $objTemplate The template object to add the enclosures to
* @param array $arrItem The element or module as array
* @param string $strKey The name of the enclosures field in $arrItem
*/
public static function addEnclosuresToTemplate($objTemplate, $arrItem, $strKey = 'enclosure')
{
$arrEnclosures = deserialize($arrItem[$strKey]);
if (!is_array($arrEnclosures) || empty($arrEnclosures)) {
return;
}
$objFiles = \FilesModel::findMultipleByUuids($arrEnclosures);
if ($objFiles === null) {
if (!\Validator::isUuid($arrEnclosures[0])) {
foreach (array('details', 'answer', 'text') as $key) {
if (isset($objTemplate->{$key})) {
$objTemplate->{$key} = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
}
}
return;
}
$file = \Input::get('file', true);
// Send the file to the browser and do not send a 404 header (see #5178)
if ($file != '') {
while ($objFiles->next()) {
if ($file == $objFiles->path) {
static::sendFileToBrowser($file);
}
}
$objFiles->reset();
}
/** @var \PageModel $objPage */
global $objPage;
$arrEnclosures = array();
$allowedDownload = trimsplit(',', strtolower(\Config::get('allowedDownload')));
// Add download links
while ($objFiles->next()) {
if ($objFiles->type == 'file') {
if (!in_array($objFiles->extension, $allowedDownload) || !is_file(TL_ROOT . '/' . $objFiles->path)) {
continue;
}
$objFile = new \File($objFiles->path, true);
$strHref = \Environment::get('request');
// Remove an existing file parameter (see #5683)
if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
$strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
}
$strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objFiles->path);
$arrMeta = \Frontend::getMetaData($objFiles->meta, $objPage->language);
if (empty($arrMeta) && $objPage->rootFallbackLanguage !== null) {
$arrMeta = \Frontend::getMetaData($objFiles->meta, $objPage->rootFallbackLanguage);
}
// Use the file name as title if none is given
if ($arrMeta['title'] == '') {
$arrMeta['title'] = specialchars($objFile->basename);
}
$arrEnclosures[] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'title' => specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename)), 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => static::getReadableSize($objFile->filesize), 'icon' => \Image::getPath($objFile->icon), 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname, 'enclosure' => $objFiles->path);
}
}
$objTemplate->enclosure = $arrEnclosures;
}