- $x->saveOembed($redir_data, $given_url);
- return $x;
- }
-
- /**
- * Save embedding information for this file, if applicable.
- *
- * Normally this won't need to be called manually, as File::saveNew()
- * takes care of it.
- *
- * @param array $redir_data lookup data eg from File_redirection::where()
- * @param string $given_url
- * @return boolean success
- */
- public function saveOembed(array $redir_data, $given_url)
- {
- if (isset($redir_data['type'])
- && (('text/html' === substr($redir_data['type'], 0, 9)
- || 'application/xhtml+xml' === substr($redir_data['type'], 0, 21)))) {
- try {
- $oembed_data = File_oembed::_getOembed($given_url);
- } catch (Exception $e) {
- return false;
- }
- if ($oembed_data === false) {
- return false;
- }
- $fo = File_oembed::getKV('file_id', $this->id);
-
- if ($fo instanceof File_oembed) {
- common_log(LOG_WARNING, "Strangely, a File_oembed object exists for new file $file_id", __FILE__);
- } else {
- File_oembed::saveNew($oembed_data, $this->id);
- return true;
- }
- }
- return false;