From d84bf834190798003cf707d861ba7e2c6073a6b9 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 23 Jul 2016 21:00:57 +0200 Subject: [PATCH 1/2] Created function File->setTitle(str) --- classes/File.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/classes/File.php b/classes/File.php index 7bd7da27ba..b0da3f09f3 100644 --- a/classes/File.php +++ b/classes/File.php @@ -693,6 +693,13 @@ class File extends Managed_DataObject return $title ?: null; } + public function setTitle($title) + { + $orig = clone($this); + $this->title = mb_strlen($title) > 0 ? $title : null; + return $this->update($orig); + } + static public function hashurl($url) { if (empty($url)) { From 563b3b1328c5fdb449847d2758cba47a06d7cf8b Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 23 Jul 2016 21:01:28 +0200 Subject: [PATCH 2/2] Using File->setTitle in oEmbed --- plugins/Oembed/OembedPlugin.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/Oembed/OembedPlugin.php b/plugins/Oembed/OembedPlugin.php index 716649c68c..187b4b9819 100644 --- a/plugins/Oembed/OembedPlugin.php +++ b/plugins/Oembed/OembedPlugin.php @@ -174,7 +174,9 @@ class OembedPlugin extends Plugin if ($oembed_data === false) { throw new Exception('Did not get oEmbed data from URL'); } + $file->setTitle($oembed_data->title); } catch (Exception $e) { + common_log(LOG_WARN, sprintf(__METHOD__.': %s thrown when getting oEmbed data: %s', get_class($e), _ve($e->getMessage()))); return true; }