diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/attach.php | 19 | ||||
-rw-r--r-- | include/conversation.php | 6 | ||||
-rw-r--r-- | include/markdown.php | 12 | ||||
-rw-r--r-- | include/photo/photo_driver.php | 2 | ||||
-rw-r--r-- | include/text.php | 1 |
5 files changed, 25 insertions, 15 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/conversation.php b/include/conversation.php index e8b8051bb..a80adb933 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1010,11 +1010,11 @@ function thread_author_menu($item, $mode = '') { $contact = App::$contacts[$item['author_xchan']]; } else { - if($local_channel && $item['author']['xchan_addr'] && (! in_array($item['author']['xchan_network'],[ 'rss', 'anon','unknown' ]))) { - $follow_url = z_root() . '/follow/?f=&url=' . urlencode($item['author']['xchan_addr']) . '&interactive=0'; + $url = (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']); + if($local_channel && $url && (! in_array($item['author']['xchan_network'],[ 'rss', 'anon','unknown' ]))) { + $follow_url = z_root() . '/follow/?f=&url=' . urlencode($url) . '&interactive=0'; } } - if($item['uid'] > 0 && author_is_pmable($item['author'],$contact)) { $pm_url = z_root() . '/mail/new/?f=&hash=' . urlencode($item['author_xchan']); } diff --git a/include/markdown.php b/include/markdown.php index 69cc264df..0bfe595b8 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -76,7 +76,7 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = html2bbcode($s); - $s = bb_code_protect($s); + // $s = bb_code_protect($s); // Convert everything that looks like a link to a link if($use_zrl) { @@ -84,13 +84,13 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = preg_replace_callback("/\[img\](.*?)\[\/img\]/ism", 'use_zrl_cb_img', $s); $s = preg_replace_callback("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", 'use_zrl_cb_img_x', $s); } - $s = preg_replace_callback("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", 'use_zrl_cb_link',$s); + $s = preg_replace_callback("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)([\,\.\:\;]\s|$)/ismu", 'use_zrl_cb_link',$s); } else { - $s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", '$1[url=$2$3]$2$3[/url]',$s); + $s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)([\,\.\:\;]\s|$)/ismu", '$1[url=$2$3]$2$3[/url]$4',$s); } - $s = bb_code_unprotect($s); + // $s = bb_code_unprotect($s); // remove duplicate adjacent code tags $s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); @@ -110,9 +110,9 @@ function use_zrl_cb_link($match) { $is_zid = is_matrix_url(trim($match[0])); if($is_zid) - $res = $match[1] . '[zrl=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/zrl]'; + $res = $match[1] . '[zrl=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/zrl]' . $match[4]; else - $res = $match[1] . '[url=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/url]'; + $res = $match[1] . '[url=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/url]' . $match[4]; return $res; } 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', |