Exemple #1
0
 public function getThumbnail(AbstractMediaEntity $entity, $width, $height, $format = 'html', $mode = 'outbound')
 {
     /* @var DeezerEntity $entity */
     $type = $entity->getMusicType();
     $id = $entity->getMusicId();
     if ($type == 'track') {
         $type = 'album';
         $id = $entity->getExtraData()['album']['id'];
     }
     //if ($mode == 'inset') {
     //    $size = max($width, $height);
     //} else if ($mode == 'outbound') {
     $size = min($width, $height);
     //}
     // @todo Ask Deezer whether it is allowed to crop the images.
     $url = "http://api.deezer.com/{$type}/{$id}/image?size=" . $size;
     switch ($format) {
         case 'url':
             return $url;
         case 'html':
             return '<img src="' . $url . '" />';
     }
     throw new \LogicException();
 }