mirror of
https://github.com/friendica/friendica
synced 2025-04-29 21:04:24 +02:00
Issue 10019: Fix embedding of media objects
This commit is contained in:
parent
60a74fd5dc
commit
262ee2b0b1
3 changed files with 34 additions and 7 deletions
|
@ -51,6 +51,30 @@ class ParseUrl
|
|||
*/
|
||||
const MIN_DESC_COUNT = 100;
|
||||
|
||||
/**
|
||||
* Fetch the content type of the given url
|
||||
* @param string $url URL of the page
|
||||
* @return string content type
|
||||
*/
|
||||
public static function getContentType(string $url)
|
||||
{
|
||||
$curlResult = DI::httpRequest()->head($url);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$contenttype = $curlResult->getHeader('Content-Type');
|
||||
if (empty($contenttype)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!preg_match('#(image|video|audio)/#i', $contenttype, $matches)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return array_pop($matches);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for chached embeddable data of an url otherwise fetch it
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue