本文整理汇总了PHP中Idno\Entities\File::isSVG方法的典型用法代码示例。如果您正苦于以下问题:PHP File::isSVG方法的具体用法?PHP File::isSVG怎么用?PHP File::isSVG使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Idno\Entities\File
的用法示例。
在下文中一共展示了File::isSVG方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveDataFromInput
/**
* Saves changes to this object based on user input
* @return bool
*/
function saveDataFromInput()
{
if (empty($this->_id)) {
$new = true;
} else {
$new = false;
}
if ($new) {
if (!\Idno\Core\Idno::site()->triggerEvent("file/upload", [], true)) {
return false;
}
}
$this->title = \Idno\Core\Idno::site()->currentPage()->getInput('title');
$this->body = \Idno\Core\Idno::site()->currentPage()->getInput('body');
$this->tags = \Idno\Core\Idno::site()->currentPage()->getInput('tags');
$access = \Idno\Core\Idno::site()->currentPage()->getInput('access');
$this->setAccess($access);
if ($time = \Idno\Core\Idno::site()->currentPage()->getInput('created')) {
if ($time = strtotime($time)) {
$this->created = $time;
}
}
// Get photo
if ($new) {
if (!empty($_FILES['photo']['tmp_name'])) {
if (\Idno\Entities\File::isImage($_FILES['photo']['tmp_name']) || \Idno\Entities\File::isSVG($_FILES['photo']['tmp_name'], $_FILES['photo']['name'])) {
// Extract exif data so we can rotate
if (is_callable('exif_read_data') && $_FILES['photo']['type'] == 'image/jpeg') {
try {
if (function_exists('exif_read_data')) {
if ($exif = exif_read_data($_FILES['photo']['tmp_name'])) {
$this->exif = base64_encode(serialize($exif));
// Yes, this is rough, but exif contains binary data that can not be saved in mongo
}
}
} catch (\Exception $e) {
$exif = false;
}
} else {
$exif = false;
}
if ($photo = \Idno\Entities\File::createFromFile($_FILES['photo']['tmp_name'], $_FILES['photo']['name'], $_FILES['photo']['type'], true, true)) {
$this->attachFile($photo);
// Now get some smaller thumbnails, with the option to override sizes
$sizes = \Idno\Core\Idno::site()->events()->dispatch('photo/thumbnail/getsizes', new \Idno\Core\Event(array('sizes' => array('large' => 800, 'medium' => 400, 'small' => 200))));
$eventdata = $sizes->data();
foreach ($eventdata['sizes'] as $label => $size) {
$filename = $_FILES['photo']['name'];
// Experiment: let's not save thumbnails for GIFs, in order to enable animated GIF posting.
if ($_FILES['photo']['type'] != 'image/gif') {
if ($thumbnail = \Idno\Entities\File::createThumbnailFromFile($_FILES['photo']['tmp_name'], "{$filename}_{$label}", $size, false)) {
$varname = "thumbnail_{$label}";
$this->{$varname} = \Idno\Core\Idno::site()->config()->url . 'file/' . $thumbnail;
$varname = "thumbnail_{$label}_id";
$this->{$varname} = substr($thumbnail, 0, strpos($thumbnail, '/'));
}
}
}
} else {
\Idno\Core\Idno::site()->session()->addErrorMessage('Image wasn\'t attached.');
}
} else {
\Idno\Core\Idno::site()->session()->addErrorMessage('This doesn\'t seem to be an image ..');
}
} else {
\Idno\Core\Idno::site()->session()->addErrorMessage('We couldn\'t access your image. Please try again.');
return false;
}
}
if ($this->save($new)) {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getTitle() . ' ' . $this->getDescription()));
return true;
} else {
return false;
}
}