function mediafront_get_media_preview in MediaFront 7.2
Same name and namespace in other branches
- 7 mediafront.module \mediafront_get_media_preview()
Returns the image path for a media object using the Media module.
Return value
array
1 call to mediafront_get_media_preview()
- mediafront_get_node in ./
mediafront.module - Provided a type, entity, and fields; this creaets a player node.
File
- ./
mediafront.module, line 530
Code
function mediafront_get_media_preview($media) {
// Make sure this is a valid media file.
if ($media->class == 'media' && module_exists('media') && !empty($media->file) && !empty($media->file->type)) {
// Get the preview thumbnail image.
$preview = media_get_thumbnail_preview($media->file);
if ($preview) {
$preview['#file'] = (object) $preview['#file'];
$markup = drupal_render($preview);
$matches = array();
preg_match('/img.*src\\=\\"(.*)\\"/U', $markup, $matches);
if (!empty($matches[1])) {
$preview = new MediaFile($matches[1]);
if ($preview->class == 'image') {
return $preview;
}
}
}
}
return '';
}