<?php
	if(isset($images)){
		$image_type = array('image/jpeg','image/jpg','image/png','image/x-png', 'image/svg+xml');
		$video_type = array('video/mp4');
		$doc_type   = array('application/msword','application/pdf');
		$audio_type = array('audio/mp3','audio/ogg','audio/mpeg');
		$zip_type = array('application/x-zip');

		$col = "col-md-2";

		foreach ($images as $key => $value) {
			$type =  get_mime_by_extension($value);
			if(in_array($type, $image_type)){
				
?>

				<div id="sort_<?php echo $id[$key]; ?>" class="<?php echo $col; ?> col-xs-3 img-box ui-sortable-handle">
					<div class="thumbnail" title="drag">
				        <img class="img-responsive" src="<?php echo $value; ?>" data-url="<?php echo $value; ?>" alt="">
				        

						<span class="remove-icon remove_selected_media" title="Remove" data-id="<?php echo $id[$key]; ?>" data-type="<?php echo $select_type; ?>"  data-field="<?php echo $field_name; ?>">Remove</span>
					</div>
					<input type="hidden" class="selected_media_ids" value="<?php echo $id[$key]; ?>" />

					<?php
			        	if(isset($caption[$key]) && $caption[$key] != ""){
			        ?>
			        		<span style="font-size: 11px;"><?php echo $caption[$key]; ?></span><br>
			        <?php
			        	}
			        ?>
				</div>
<?php
			}else if(in_array($type, $doc_type)){
?>
					<div id="sort_<?php echo $id[$key]; ?>" class="<?php echo $col; ?> col-xs-3 img-box ui-sortable-handle">
						<div class="thumbnail" title="drag">
					        <a href="<?php echo $value ?>" target="_blank"><img class="img-responsive" src="<?php echo base_url('assets/images/pdf.svg'); ?>" class="img-responsive"></a>
					            
							<span class="remove-icon remove_selected_media" title="Remove" data-id="<?php echo $id[$key]; ?>" data-type="<?php echo $select_type; ?>"  data-field="<?php echo $field_name; ?>">Remove</span>
						</div>
						<input type="hidden" class="selected_media_ids" value="<?php echo $id[$key]; ?>" />

						<?php
				        	if(isset($caption[$key]) && $caption[$key] != ""){
				        ?>
				        		<span style="font-size: 11px;"><?php echo $caption[$key]; ?></span><br>
				        <?php
				        	}
				        ?>
					</div>
<?php
			}else if(in_array($type, $zip_type)){
?>
					<div id="sort_<?php echo $id[$key]; ?>" class="<?php echo $col; ?> col-xs-3 img-box ui-sortable-handle">
						<div class="thumbnail" title="drag">
					        <a href="<?php echo $value ?>" target="_blank"><img class="img-responsive" src="<?php echo base_url('assets/images/zip.png'); ?>" class="img-responsive"></a>
					            
							<span class="remove-icon remove_selected_media" title="Remove" data-id="<?php echo $id[$key]; ?>" data-type="<?php echo $select_type; ?>"  data-field="<?php echo $field_name; ?>">Remove</span>
						</div>
						<input type="hidden" class="selected_media_ids" value="<?php echo $id[$key]; ?>" />

						<?php
				        	if(isset($caption[$key]) && $caption[$key] != ""){
				        ?>
				        		<span style="font-size: 11px;"><?php echo $caption[$key]; ?></span><br>
				        <?php
				        	}
				        ?>
					</div>
<?php
			}else if(in_array($type, $video_type)){
?>
					<div id="sort_<?php echo $id[$key]; ?>" class="<?php echo $col; ?> col-xs-3 img-box ui-sortable-handle">
						<div class="thumbnail" title="drag">
					        <a href="<?php echo $value ?>" target="_blank"><img class="img-responsive" src="<?php echo base_url().'assets/images/video.png'; ?>" class="img-responsive"></a>
					            
							<span class="remove-icon remove_selected_media" title="Remove" data-id="<?php echo $id[$key]; ?>" data-type="<?php echo $select_type; ?>"  data-field="<?php echo $field_name; ?>">Remove</span>
						</div>
						<input type="hidden" class="selected_media_ids" value="<?php echo $id[$key]; ?>" />

						<?php
				        	if(isset($caption[$key]) && $caption[$key] != ""){
				        ?>
				        		<span style="font-size: 11px;"><?php echo $caption[$key]; ?></span><br>
				        <?php
				        	}
				        ?>
					</div>
<?php
			}else{
?>
					<div id="sort_<?php echo $id[$key]; ?>" class="<?php echo $col; ?> col-xs-3 img-box ui-sortable-handle">
						<div class="thumbnail" title="drag">
					        <a href="<?php echo $value ?>" target="_blank"><img class="img-responsive" src="<?php echo $value; ?>" data-url="<?php echo base_url('uploads/media/source/'.$value); ?>" class="img-responsive"></a>
					            
							<span class="remove-icon remove_selected_media" title="Remove" data-id="<?php echo $id[$key]; ?>" data-type="<?php echo $select_type; ?>"  data-field="<?php echo $field_name; ?>">Remove</span>
						</div>
						<input type="hidden" class="selected_media_ids" value="<?php echo $id[$key]; ?>" />

						<?php
				        	if(isset($caption[$key]) && $caption[$key] != ""){
				        ?>
				        		<span style="font-size: 11px;"><?php echo $caption[$key]; ?></span><br>
				        <?php
				        	}
				        ?>
					</div>
<?php
			}
		}
	}
?>