コード例 #1
0
ファイル: core.php プロジェクト: ejoan/erikajoan.com
 /**
  * Function to create a preview thumbnail for video
  * 
  * @param object | int $video contain all information about the video or the id
  * @return string result code
  * @author Praveen Rajan
  */
 function create_thumbnail_video($video)
 {
     $options = get_option('cvg_settings');
     $thumb_width = $options['cvg_preview_width'];
     $thumb_height = $options['cvg_preview_height'];
     if (is_numeric($video)) {
         $video = videoDB::find_video($video);
     }
     $video = $video[0];
     if (!is_object($video)) {
         return __('Object didn\'t contain correct data');
     }
     $filepart = CvgCore::fileinfo($video->filename);
     // check for allowed extension and if it's an image file
     $ext = array('mp4', 'flv', 'MP4', 'FLV', 'mov', 'MOV');
     if (!in_array($filepart['extension'], $ext)) {
         return;
     }
     $video_input = $this->winabspath . $video->path . '/' . $video->filename;
     $new_target_filename = $video->alttext . '.png';
     $new_target_file = $this->winabspath . $video->path . '/thumbs/thumbs_' . $new_target_filename;
     $video_preview = $this->winabspath . $video->path . '/thumbs/thumbs_' . $video->alttext . '_preview.png';
     $command = $options['cvg_ffmpegpath'] . " -i '{$video_input}' -vcodec mjpeg -vframes 1 -an -f rawvideo -ss 5 -s " . $thumb_width . "x" . $thumb_height . " '{$new_target_file}'";
     exec($command);
     $command = $options['cvg_ffmpegpath'] . " -i '{$video_input}' -vcodec mjpeg -vframes 1 -an -f rawvideo -ss 5 -s " . $thumb_width . "x" . $thumb_height . " '{$video_preview}'";
     exec($command);
     //get video duration
     $video_duration = CvgCore::video_duration($video_input);
     if (file_exists($new_target_file)) {
         CvgCore::chmod($new_target_file);
         CvgCore::chmod($video_preview);
         /*$options = get_option('cvg_settings');
         			$thumb_width = $options['cvg_preview_width'];
         			$thumb_height = $options['cvg_preview_height'];
         			$cv_zc = $options['cvg_zc'];
         			$thumb_quality = $options['cvg_preview_quality'];
         		
         			if($cv_zc == 1)
         				$crop = true;
         			elseif($cv_zc == 0)
         				$crop = false;
         					
         			$image_details = @getimagesize($new_target_file);
         			if($image_details[0] > $thumb_width && $image_details[1] > $thumb_height){ 	
         				$new_file = image_resize( $new_target_file, $thumb_width, $thumb_height, $crop, 'thumbs', NULL, $thumb_quality ); 	
         				@unlink($new_target_file); 	
         				@rename($new_file, $new_target_file); 	
         			} 
         				
         			$new_size = @getimagesize ( $new_target_file );
         			$size ['width'] = $new_size [0];
         			$size ['height'] = $new_size [1];
         			*/
         // add them to the database
         videoDB::update_video_meta($video->pid, array('video_thumbnail' => $size, 'videoDuration' => $video_duration));
     }
 }
コード例 #2
0
ファイル: core.php プロジェクト: axovel/easycarcare
    /**
     * Function for show tab for media videos
     * 
     * @author Praveen Rajan
     */
    function tab_addmedia()
    {
        ?>
    	<!-- Add youtube videos -->
    	<h2><?php 
        _e('Attach Media');
        ?>
</h2>
    	<form name="addmedia" id="addmedia_form" method="POST"  action="<?php 
        echo admin_url('admin.php?page=cvg-gallery-add') . '#addmedia';
        ?>
" accept-charset="utf-8" >
			<table class="form-table"> 
			<tr valign="top"> 
				<th scope="row"><?php 
        _e('Choose Media from Library');
        ?>
</th> 
				<td>
					<select name="mediaselect_add" id="mediaselect_add">
					<option value="0" ><?php 
        _e('Choose media');
        ?>
</option>
					<?php 
        $cool_video_gallery = new CoolVideoGallery();
        $ext = $cool_video_gallery->allowed_extension;
        $args = array('post_type' => 'attachment', 'post_mime_type' => 'video');
        $mediafiles = get_posts($args);
        foreach ($mediafiles as $file) {
            $filepart = CvgCore::fileinfo($file->guid);
            if (in_array($filepart['extension'], $ext)) {
                $name = empty($file->post_name) ? $file->post_title : $file->post_name;
                echo '<option value="' . $file->ID . '" >' . $name . '</option>' . "\n";
            }
        }
        $args_audio = array('post_type' => 'attachment', 'post_mime_type' => 'audio');
        $mediafiles_audio = get_posts($args_audio);
        foreach ($mediafiles_audio as $file) {
            $filepart = CvgCore::fileinfo($file->guid);
            if (in_array($filepart['extension'], $ext)) {
                $name = empty($file->post_name) ? $file->post_title : $file->post_name;
                echo '<option value="' . $file->ID . '" >' . $name . '</option>' . "\n";
            }
        }
        ?>
					</select>
					
				</td>
			</tr> 
			<tr valign="top"> 
				<th scope="row"><?php 
        _e('in to');
        ?>
</th> 
				<td>
				<select name="galleryselect_media" id="galleryselect_media">
				<option value="0" ><?php 
        _e('Choose gallery');
        ?>
</option>
				<?php 
        $gallerylist = videoDB::find_all_galleries('gid', 'ASC');
        foreach ($gallerylist as $gallery) {
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . $name . '</option>' . "\n";
        }
        ?>
				</select>
			</tr> 
			</table>
			<?php 
        wp_nonce_field('cvg_add_media_nonce', 'cvg_add_media_nonce_csrf');
        ?>
			<div class="submit">
				<input type="hidden" value="Add Media" name="addmedia" />
				<input class="button-primary" type="button" name="addmedia_btn" id="addmedia_btn" value="<?php 
        _e('Add Media');
        ?>
" />
			</div>
		</form>
		
    <?php 
    }