diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2021-01-17 21:09:31 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2021-01-19 20:17:10 +0100 |
commit | 6d4afca7ace0b62f4256b18a0cab60f180ebbc07 (patch) | |
tree | d9659629bbfa8bf45dabffb2ad2c4387e161d16e /lib/private/Preview | |
parent | 3406032cf8ff3062329dd7a18937a2ec3dbfbf8d (diff) | |
download | nextcloud-server-6d4afca7ace0b62f4256b18a0cab60f180ebbc07.tar.gz nextcloud-server-6d4afca7ace0b62f4256b18a0cab60f180ebbc07.zip |
Add support for webp
Including handling in OC_Image
But also a preview provider
Of course only works if your php actually supports webp
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Preview')
-rw-r--r-- | lib/private/Preview/WebP.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/private/Preview/WebP.php b/lib/private/Preview/WebP.php new file mode 100644 index 00000000000..8f10a08206b --- /dev/null +++ b/lib/private/Preview/WebP.php @@ -0,0 +1,42 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author John Molakvoæ <skjnldsv@protonmail.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Preview; + +use OCP\Files\FileInfo; + +class WebP extends Image { + /** + * {@inheritDoc} + */ + public function getMimeType(): string { + return '/image\/webp/'; + } + + public function isAvailable(FileInfo $file): bool { + return (bool)(imagetypes() && IMG_WEBP); + } +} |