mirror of
https://github.com/friendica/friendica
synced 2025-04-25 03:50:12 +00:00
Image handling reworked, new image formats added (#13900)
* Image handling reworked, new image formats added * Updated messages.po * The dot is now part of the file extension * Added WebP in install documentation * Handle unhandled mime types * Fixed animated picture detected
This commit is contained in:
parent
1ea8a4042d
commit
14e5b06029
31 changed files with 541 additions and 386 deletions
|
@ -40,6 +40,7 @@ use Friendica\Model\Post;
|
|||
use Friendica\Model\Tag;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\Map;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\ParseUrl;
|
||||
|
@ -1027,12 +1028,12 @@ class BBCode
|
|||
if (is_null($text)) {
|
||||
$curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
|
||||
$mimetype = $curlResult->getContentType() ?? '';
|
||||
} else {
|
||||
$mimetype = '';
|
||||
}
|
||||
|
||||
if (substr($mimetype, 0, 6) == 'image/') {
|
||||
if (Images::isSupportedMimeType($mimetype)) {
|
||||
$text = '[url=' . $match[1] . ']' . $match[1] . '[/url]';
|
||||
} else {
|
||||
$text = '[url=' . $match[2] . ']' . $match[2] . '[/url]';
|
||||
|
@ -1125,13 +1126,13 @@ class BBCode
|
|||
|
||||
$curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
|
||||
$mimetype = $curlResult->getContentType() ?? '';
|
||||
} else {
|
||||
$mimetype = '';
|
||||
}
|
||||
|
||||
// if its a link to a picture then embed this picture
|
||||
if (substr($mimetype, 0, 6) == 'image/') {
|
||||
if (Images::isSupportedMimeType($mimetype)) {
|
||||
$text = '[img]' . $match[1] . '[/img]';
|
||||
} else {
|
||||
if (!empty($match[3])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue