aboutsummaryrefslogtreecommitdiff
path: root/classes/File.php
diff options
context:
space:
mode:
authorMikael Nordfeldth <mmn@hethane.se>2016-01-07 17:35:37 +0100
committerMikael Nordfeldth <mmn@hethane.se>2016-01-07 17:35:37 +0100
commitd4be5349b30f49fa049dbfc854bb2a95eeb1d5c1 (patch)
tree62c491fc4aeb10dfe3f8bdf9a3a7800810485636 /classes/File.php
parent9e5c71e701a5f1a6647a2dadcf7d68746c9b968e (diff)
downloadgnu-social-d4be5349b30f49fa049dbfc854bb2a95eeb1d5c1.tar
gnu-social-d4be5349b30f49fa049dbfc854bb2a95eeb1d5c1.zip
think I have managed to show oEmbed images better now
Diffstat (limited to 'classes/File.php')
-rw-r--r--classes/File.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/classes/File.php b/classes/File.php
index a3ded46ec9..2390f848de 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -356,28 +356,47 @@ class File extends Managed_DataObject
return $protocol.'://'.$server.$path.$filename;
}
+ static $_enclosures = array();
+
function getEnclosure(){
+ if (isset(self::$_enclosures[$this->getID()])) {
+ common_debug('Found cached enclosure for file id=='.$this->getID());
+ return self::$_enclosures[$this->getID()];
+ }
+
$enclosure = (object) array();
foreach (array('title', 'url', 'date', 'modified', 'size', 'mimetype') as $key) {
$enclosure->$key = $this->$key;
}
- $needMoreMetadataMimetypes = array(null, 'application/xhtml+xml');
+ $needMoreMetadataMimetypes = array(null, 'application/xhtml+xml', 'text/html');
if (!isset($this->filename) && in_array(common_bare_mime($enclosure->mimetype), $needMoreMetadataMimetypes)) {
// This fetches enclosure metadata for non-local links with unset/HTML mimetypes,
// which may be enriched through oEmbed or similar (implemented as plugins)
Event::handle('FileEnclosureMetadata', array($this, &$enclosure));
}
- if (empty($enclosure->mimetype) || in_array(common_bare_mime($enclosure->mimetype), $needMoreMetadataMimetypes)) {
+ if (empty($enclosure->mimetype)) {
// This means we either don't know what it is, so it can't
// be shown as an enclosure, or it is an HTML link which
// does not link to a resource with further metadata.
throw new ServerException('Unknown enclosure mimetype, not enough metadata');
}
+
+ self::$_enclosures[$this->getID()] = $enclosure;
return $enclosure;
}
+ public function hasThumbnail()
+ {
+ try {
+ $this->getThumbnail();
+ } catch (Exception $e) {
+ return false;
+ }
+ return true;
+ }
+
/**
* Get the attachment's thumbnail record, if any.
* Make sure you supply proper 'int' typed variables (or null).