本文整理匯總了PHP中SimpleImage::getExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleImage::getExtension方法的具體用法?PHP SimpleImage::getExtension怎麽用?PHP SimpleImage::getExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SimpleImage
的用法示例。
在下文中一共展示了SimpleImage::getExtension方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: bindImage
public function bindImage($elementName)
{
$file = JRequest::getVar($elementName, '', 'FILES');
if (!isset($file['tmp_name']) || empty($file['tmp_name'])) {
return false;
}
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
// @task: Test if the folder containing the badges exists
if (!JFolder::exists(DISCUSS_BADGES_PATH)) {
JFolder::create(DISCUSS_BADGES_PATH);
}
// @task: Test if the folder containing uploaded badges exists
if (!JFolder::exists(DISCUSS_BADGES_UPLOADED)) {
JFolder::create(DISCUSS_BADGES_UPLOADED);
}
require_once DISCUSS_CLASSES . '/simpleimage.php';
$image = new SimpleImage();
$image->load($file['tmp_name']);
if ($image->getWidth() > 64 || $image->getHeight() > 64) {
return false;
}
$storage = DISCUSS_BADGES_UPLOADED;
$name = md5($this->id . DiscussHelper::getDate()->toMySQL()) . $image->getExtension();
// @task: Create the necessary path
$path = $storage . '/' . $this->id;
if (!JFolder::exists($path)) {
JFolder::create($path);
}
// @task: Copy the original image into the storage path
JFile::copy($file['tmp_name'], $path . '/' . $name);
// @task: Resize to the 16x16 favicon
$image->resize(DISCUSS_BADGES_FAVICON_WIDTH, DISCUSS_BADGES_FAVICON_HEIGHT);
$image->save($path . '/' . 'favicon_' . $name);
$this->avatar = $this->id . '/' . $name;
$this->thumbnail = $this->id . '/' . 'favicon_' . $name;
return $this->store();
}