aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2019-12-07 20:14:17 +0100
committerMario <mario@mariovavti.com>2019-12-07 20:14:17 +0100
commitaed682305173a67b2af1a56b8595445bec690e2b (patch)
treea022f3769332331a9c30f4b96a81a6b854690767 /include
parent96f9e515466b749d1e1640aad3fd25bc19399f1a (diff)
downloadvolse-hubzilla-aed682305173a67b2af1a56b8595445bec690e2b.tar.gz
volse-hubzilla-aed682305173a67b2af1a56b8595445bec690e2b.tar.bz2
volse-hubzilla-aed682305173a67b2af1a56b8595445bec690e2b.zip
Add .webp image format support
Diffstat (limited to 'include')
-rw-r--r--include/attach.php19
-rw-r--r--include/photo/photo_driver.php2
-rw-r--r--include/text.php1
3 files changed, 16 insertions, 6 deletions
diff --git a/include/attach.php b/include/attach.php
index 80efe0838..952270949 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -56,6 +56,7 @@ function z_mime_content_type($filename) {
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
+ 'webp' => 'image/webp',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
@@ -616,7 +617,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$is_photo = 0;
$gis = @getimagesize($src);
logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA);
- if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) {
+ if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG || $gis[2] === IMAGETYPE_WEBP)) {
$is_photo = 1;
if($gis[2] === IMAGETYPE_GIF)
$def_extension = '.gif';
@@ -624,6 +625,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$def_extension = '.jpg';
if($gis[2] === IMAGETYPE_PNG)
$def_extension = '.png';
+ if($gis[2] === IMAGETYPE_WEBP)
+ $def_extension = '.webp';
}
// If we know it's a photo, over-ride the type in case the source system could not determine what it was
@@ -908,7 +911,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
);
}
- if($is_photo) {
+ if($is_photo && $r) {
$args = array( 'source' => $source, 'visible' => $visible, 'resource_id' => $hash, 'album' => $pathname, 'os_syspath' => $os_basepath . $os_relpath, 'os_path' => $os_path, 'display_path' => $display_path, 'filename' => $filename, 'getimagesize' => $gis, 'directory' => $direct, 'options' => $options );
if($arr['contact_allow'])
@@ -942,9 +945,15 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$args['deliver'] = $dosync;
$p = photo_upload($channel,$observer,$args);
- if($p['success']) {
- $ret['body'] = $p['body'];
+ if($p['success'])
+ $ret['body'] = $p['body'];
+ else {
+ // Attach as ordinary file if image processing is failed
+ $x = q("UPDATE attach SET is_photo = 0 WHERE hash = '%s'",
+ dbesc($hash)
+ );
}
+
}
if(($options !== 'update') && ($remove_when_processed))
@@ -2654,5 +2663,3 @@ function save_chunk($channel,$start,$end,$len) {
$result['length'] = intval(filesize($new_path));
return $result;
}
-
-
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index c11580bdc..284206161 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -135,6 +135,8 @@ function guess_image_type($filename, $headers = '') {
$type = 'image/gif';
elseif(strpos(strtolower($filename),'png') !== false)
$type = 'image/png';
+ elseif(strpos(strtolower($filename),'webp') !== false)
+ $type = 'image/webp';
}
}
diff --git a/include/text.php b/include/text.php
index eba41521d..87ed9f658 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2992,6 +2992,7 @@ function getIconFromType($type) {
'image/jpeg' => 'fa-picture-o',
'image/png' => 'fa-picture-o',
'image/gif' => 'fa-picture-o',
+ 'image/webp' => 'fa-picture-o',
'image/svg+xml' => 'fa-picture-o',
//Archive
'application/zip' => 'fa-file-archive-o',