Ejemplo n.º 1
0
 function cl_video_tag($source, $options = array())
 {
     $source = preg_replace('/\\.(' . implode('|', default_source_types()) . ')$/', '', $source);
     $source_types = Cloudinary::option_consume($options, 'source_types', array());
     $source_transformation = Cloudinary::option_consume($options, 'source_transformation', array());
     $fallback = Cloudinary::option_consume($options, 'fallback_content', '');
     if (empty($source_types)) {
         $source_types = default_source_types();
     }
     $video_options = $options;
     if (array_key_exists('poster', $video_options)) {
         if (is_array($video_options['poster'])) {
             if (array_key_exists('public_id', $video_options['poster'])) {
                 $video_options['poster'] = cloudinary_url_internal($video_options['poster']['public_id'], $video_options['poster']);
             } else {
                 $video_options['poster'] = cl_video_thumbnail_path($source, $video_options['poster']);
             }
         }
     } else {
         $video_options['poster'] = cl_video_thumbnail_path($source, $options);
     }
     if (empty($video_options['poster'])) {
         unset($video_options['poster']);
     }
     $html = '<video ';
     if (!array_key_exists('resource_type', $video_options)) {
         $video_options['resource_type'] = 'video';
     }
     $multi_source = is_array($source_types);
     if (!$multi_source) {
         $source .= '.' . $source_types;
     }
     $src = cloudinary_url_internal($source, $video_options);
     if (!$multi_source) {
         $video_options['src'] = $src;
     }
     if (isset($video_options["html_width"])) {
         $video_options['width'] = Cloudinary::option_consume($video_options, 'html_width');
     }
     if (isset($video_options['html_height'])) {
         $video_options['height'] = Cloudinary::option_consume($video_options, 'html_height');
     }
     $html .= Cloudinary::html_attrs($video_options) . '>';
     if ($multi_source) {
         foreach ($source_types as $source_type) {
             $transformation = Cloudinary::option_consume($source_transformation, $source_type, array());
             $transformation = array_merge($options, $transformation);
             $src = cl_video_path($source . '.' . $source_type, $transformation);
             $video_type = $source_type == 'ogv' ? 'ogg' : $source_type;
             $mime_type = "video/{$video_type}";
             $html .= '<source ' . Cloudinary::html_attrs(array('src' => $src, 'type' => $mime_type)) . '>';
         }
     }
     $html .= $fallback;
     $html .= '</video>';
     return $html;
 }
Ejemplo n.º 2
0
 public function test_cl_video_thumbnail_path()
 {
     $this->assertEquals(cl_video_thumbnail_path('movie_id'), CloudinaryTest::VIDEO_UPLOAD_PATH . "movie_id.jpg");
     $this->assertEquals(cl_video_thumbnail_path('movie_id', array('width' => 100)), CloudinaryTest::VIDEO_UPLOAD_PATH . "w_100/movie_id.jpg");
 }