本文整理汇总了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();
}