You are here

function mediafront_get_media_preview in MediaFront 7

Same name and namespace in other branches
  1. 7.2 mediafront.module \mediafront_get_media_preview()

Returns the image path for a media object.

Return value

array

2 calls to mediafront_get_media_preview()
mediafront_get_playlist_from_view in ./mediafront.module
Returns a playlist provided a view.
mediafront_playlist_node in ./mediafront.module
Implements hook_playlist_node()

File

./mediafront.module, line 787

Code

function mediafront_get_media_preview($media) {
  $media = (object) $media;
  if (isset($media->type) && $media->type != 'image' && mediafront_is_media($media->type, mediafront_get_extension($media->filename))) {
    $preview = media_get_thumbnail_preview((object) $media);
    if ($preview) {
      $preview['#file'] = (object) $preview['#file'];
      $markup = drupal_render($preview);
      $matches = array();
      preg_match('/img.*src\\=\\"(.*)\\"/U', $markup, $matches);
      if (isset($matches[1]) && mediafront_is_image('', mediafront_get_extension($matches[1]))) {
        return $matches[1];
      }
    }
  }
  return '';
}