function mediafront_get_media_file in MediaFront 6
Same name and namespace in other branches
- 6.2 mediafront.module \mediafront_get_media_file()
- 7 mediafront.module \mediafront_get_media_file()
Given a Drupal file object, this function returns the media player file object.
Parameters
object $file - The Drupal file to use when determining the media player file object.:
Return value
object - The media player file object, if it is valid.
1 call to mediafront_get_media_file()
- mediafront_add_media in ./
mediafront.module - Function that will add media to the $additions array
File
- ./
mediafront.module, line 745
Code
function mediafront_get_media_file($file) {
$media_file = new stdClass();
$media_file->path = mediafront_get_media_filepath($file);
$media_file->extension = mediafront_get_extension($media_file->path);
if (isset($file->class) && isset($file->mediaType)) {
$media_file->class = $file->class;
$media_file->mediaType = $file->mediaType;
}
else {
if (mediafront_is_image($file->filemime, $media_file->extension)) {
$media_file->class = "images";
$media_file->mediaType = "image";
}
else {
if (mediafront_is_media($file->filemime, $media_file->extension)) {
$media_file->class = "media";
$media_file->mediaType = $file->mediaType ? $file->mediaType : "media";
}
else {
$media_file->class = "";
$media_file->mediaType = "";
}
}
}
$media_file->player = isset($file->player) ? $file->player : '';
$media_file->bytesTotal = isset($file->filesize) ? $file->filesize : 0;
$media_file->duration = isset($file->duration) ? $file->duration : 0;
$media_file->width = isset($file->width) ? $file->width : 0;
$media_file->height = isset($file->height) ? $file->height : 0;
return $media_file;
}