function oembed_url_to_file in oEmbed 7.0
Same name and namespace in other branches
- 8 oembed.module \oembed_url_to_file()
- 7 oembed.module \oembed_url_to_file()
Return a file entity for a URL. Create the file if necessary.
Parameters
type $url:
type $create:
Return value
type
6 calls to oembed_url_to_file()
- MediaInternetOEmbedHandler::getFileObject in ./
MediaInternetOEmbedHandler.inc - Returns a file object which can be used for validation
- OembedFileEntityTestCase::testOembedFileFormatters in ./
oembed.test - Tests the oembed render element types.
- OembedFileEntityTestCase::testOembedImageFileFormatters in ./
oembed.test - Tests the oembed render element types.
- oembed_entity_insert in ./
oembed.filter.inc - Implements hook_entity_insert().
- oembed_pre_render_wysiwyg in ./
oembed.module - Converts oEmbed response to a plain image.
File
- ./
oembed.module, line 852
Code
function oembed_url_to_file($url, $create = FALSE) {
$uri = 'oembed://' . drupal_encode_path($url);
$file = file_uri_to_object($uri);
if (!isset($file->oembed)) {
$file->oembed = oembed_get_data($url);
}
// New URLs need to be validated before being saved.
if ($create && !isset($file->fid)) {
// Save the new file.
file_save($file);
}
return $file;
}