ik heb een leuk script gevonden voor mijn foto's te bewaren. hierbij kan ik ook mp4 laten afspelen.
echter bij de thumbs zit ik met een vaste afbeelding voor iedere mp4 (foliogallery/images/video.png) ik heb ondertussen al gevonden als ik dit verander naar ($mp4_thumb = $album.'/thumbs/'.$filename.'.jpg';) kan ik een gepersonaliseerde jpg weergeven van de mp4.
maar hoe kan ik dit programmeren indien er geen gepersonaliseerde jpg bestaat toch de vaste afbeelding wordt weergegeven?
waarschijnlijk met de echo functie maar ik heb echter zero kennis van php.
alvast bedankt voor de hulp.
uitgeknipt stukje script
------------------------
<?php
foreach($files as $file)
{
if(isset($file) && is_file($album .'/'. $file))
{
$file_parts = pathinfo($file);
$filename = $file_parts['filename'];
$ext = $file_parts['extension'];
$full_caption = (itemDescription($album, $file) ? itemDescription($album, $file) : $file); // image captions
$caption = encodeto($full_caption);
if (file_exists($album.'/thumbs/'.$file))
{
$thumb = '<img src="'.$album.'/thumbs/'.$file.'" alt="'.$file.'" />';
}
else
{
if($ext=='mp4')
{
//$mp4_thumb = file_exists($album .'/thumbs/'.$filename.'.jpg') ? $filename.'.jpg' : 'foliogallery/images/mp4.png';
//$thumb = '<img src="'.$album.'/thumbs/'.$mp4_thumb.'" alt="" />';
$mp4_thumb = 'foliogallery/images/video.png';
$thumb = '<img src="'.$mp4_thumb.'" alt="'.$file.'" />';
}
?>
<!--
folioGallery v3.1 - 2017-09-18
(c) 2017 Harry Ghazanian - foliopages.com/php-jquery-ajax-photo-gallery-no-database
This content is released under the http://www.opensource.org/licenses/mit-license.php MIT License.
-->
<?php
include 'foliogallery/config.php';
$targetid = isset($_POST['targetid']) ? $_POST['targetid'] : ''; // id of gallery or album
?>
<div class="fg">
<?php
if (empty($_REQUEST['album'])) // if no album requested, show all albums
{
$albums = array();
$albums = glob($mainFolder.'/*', GLOB_ONLYDIR); // scan only directories
$numAlbums = count($albums);
// sort the abums array
if($sort_albums == 'newest')
{
array_multisort(array_map('filemtime', $albums ), SORT_NUMERIC, SORT_DESC, $albums);
}
elseif($sort_albums == 'oldest')
{
array_multisort(array_map('filemtime', $albums ), SORT_NUMERIC, SORT_ASC, $albums);
}
else
{
sort($sort_albums);
}
if($numAlbums == 0)
{
echo '<div class="titlebar"><p>No albums posted</p></div>';
}
else
{
if($show_title)
{ ?>
<span class="title m5-left">Photo Gallery - <?php echo $numAlbums; ?> albums</span>
<div class="clear"></div>
<?php
} ?>
<div class="thumbwrap-outer">
<?php
if($show_nav)
{ ?>
<!--<a href="#" class="toleft"><span class="fgleft"></span></a>
<a href="#" class="toright"><span class="fgright"></span></a>-->
<a href="#" class="fgleft"></a>
<a href="#" class="fgright"></a>
<?php
} ?>
<div class="thumbwrap" title="<?php echo $numAlbums; ?>">
<div class="thumbwrap-inner">
<?php
foreach($albums as $album)
{
$album = basename($album); // extract folder name from path
$thumb_pool = glob($mainFolder.'/'.$album.'/*.{'.$supported_extensions.'}', GLOB_BRACE);
if (count($thumb_pool) == 0)
{
$thumb = $no_thumb;
}
else
{
$rand_thumb = ($random_thumbs ? $thumb_pool[array_rand($thumb_pool)] : $thumb_pool[0]); // display a random thumb or the 1st thumb
$rand_thumb = basename($rand_thumb);
if(file_exists($mainFolder.'/'.$album.'/thumbs/'.$rand_thumb))
{
$thumb = '<img src="'.$mainFolder.'/'.$album.'/thumbs/'.$rand_thumb.'" alt="'.$rand_thumb.'" />';
}
else
{
$file_parts = pathinfo($rand_thumb);
$filename = $file_parts['filename'];
$ext = $file_parts['extension'];
if($ext=='mp4')
{
//$mp4_thumb = file_exists($album .'/thumbs/'.$filename.'.jpg') ? $filename.'.jpg' : 'foliogallery/images/mp4.png';
//$thumb = '<img src="'.$album.'/thumbs/'.$mp4_thumb.'" alt="" />';
$mp4_thumb = 'foliogallery/images/video.png';
$thumb = '<img src="'.$mp4_thumb.'" alt="'.$album.'" />';
}
elseif($ext=='mp3')
{
//$mp3_thumb = file_exists($album .'/thumbs/'.$filename.'.jpg') ? $filename.'.jpg' : 'foliogallery/images/mp3.png';
//$thumb = '<img src="'.$album.'/thumbs/'.$mp3_thumb.'" alt="" />';
$mp3_thumb = 'foliogallery/images/note.png';
$thumb = '<img src="'.$mp3_thumb.'" alt="'.$album.'" />';
}
else
{
$thumb = $no_thumb;
}
}
} ?>
<div class="thumb">
<div class="thumb-itself">
<a class="showAlb" rel="<?php echo $album; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?album=<?php echo urlencode($album); ?>">
<?php echo $thumb; ?>
</a>
</div>
<div class="clear"></div>
<div class="caption"><?php echo $album; ?></div>
</div>
<?php
} ?>
</div>
</div>
</div>
<?php
}
}
else //display photos in album
{
$requested_album = sanitize($_REQUEST['album']); // xss prevention
$album = $mainFolder.'/'.$requested_album;
$scan_files = array();
$scan_files = glob($album.'/*.{'.$supported_extensions.'}', GLOB_BRACE);
$numFiles = count($scan_files);
// sort the files array
if($sort_files == 'newest')
{
array_multisort(array_map('filemtime', $scan_files ), SORT_NUMERIC, SORT_DESC, $scan_files);
}
elseif($sort_files == 'oldest')
{
array_multisort(array_map('filemtime', $scan_files ), SORT_NUMERIC, SORT_ASC, $scan_files);
}
else
{
sort($scan_files);
}
$files = array();
foreach($scan_files as $f) { $files[] = basename($f); }
if($show_title)
{
if($fullAlbum==1)
{ ?>
<a class="title refresh m5-left" href="#">Index</a>
<span class="navigate-next"></span>
<span class="title"><?php echo $requested_album; ?> - <?php echo $numFiles; ?> images</span>
<?php
}
else
{ ?>
<span class="title m5-left"><?php echo $requested_album; ?> - <?php echo $numFiles; ?> images</span>
<?php
} ?>
<div class="clear"></div>
<?php
}
if($numFiles == 0)
{
echo '<div class="clear"></div>There are no images in this album.';
}
else
{
if (!is_dir($album.'/thumbs'))
{
mkdir($album.'/thumbs');
chmod($album.'/thumbs', 0777);
//chown($album.'/thumbs', 'apache');
} ?>
<div class="thumbwrap-outer">
<?php
if($show_nav)
{ ?>
<!--<a href="#" class="toleft"><span class="fgleft"></span></a>
<a href="#" class="toright"><span class="fgright"></span></a>-->
<a href="#" class="fgleft"></a>
<a href="#" class="fgright"></a>
<?php
} ?>
<div class="thumbwrap" title="<?php echo $numFiles; ?>">
<div class="thumbwrap-inner">
<?php
foreach($files as $file)
{
if(isset($file) && is_file($album .'/'. $file))
{
$file_parts = pathinfo($file);
$filename = $file_parts['filename'];
$ext = $file_parts['extension'];
$full_caption = (itemDescription($album, $file) ? itemDescription($album, $file) : $file); // image captions
$caption = encodeto($full_caption);
if (file_exists($album.'/thumbs/'.$file))
{
$thumb = '<img src="'.$album.'/thumbs/'.$file.'" alt="'.$file.'" />';
}
else
{
if($ext=='mp4')
{
//$mp4_thumb = file_exists($album .'/thumbs/'.$filename.'.jpg') ? $filename.'.jpg' : 'foliogallery/images/mp4.png';
//$thumb = '<img src="'.$album.'/thumbs/'.$mp4_thumb.'" alt="" />';
$mp4_thumb = 'foliogallery/images/video.png';
$thumb = '<img src="'.$mp4_thumb.'" alt="'.$file.'" />';
}
elseif($ext=='mp3')
{
//$mp3_thumb = file_exists($album .'/thumbs/'.$filename.'.jpg') ? $filename.'.jpg' : 'foliogallery/images/mp3.png';
//$thumb = '<img src="'.$album.'/thumbs/'.$mp3_thumb.'" alt="" />';
$mp3_thumb = 'foliogallery/images/note.png';
$thumb = '<img src="'.$mp3_thumb.'" alt="'.$file.'" />';
}
else
{
make_thumb($album,$file,$album.'/thumbs/'.$file,$make_thumb_width);
}
}
?>
<div class="thumb">
<div class="thumb-itself"><?php echo url_start($album,$file).$thumb.$url_end; ?></div>
<?php
if($show_captions)
{ ?>
<div class="clear"></div>
<div class="caption">
<a href="#" class="tooltip" rev="<?php echo $caption; ?>"><?php echo $caption; ?></a>
</div>
<?php
} ?>
</div>
<?php
}
} ?>
</div>
</div>
</div>
<?php
if($show_descriptions)
{
echo (file_exists($album.'/descriptions.txt') ? '<div class="description-wrapper">'.encodeto(itemDescription($album)).'</div>' : ''); //display album description
}
} // end if numFiles not 0
} ?>
</div>
<div id="fgOverlay"></div>
<script>
$(function() {
var targetid = <?php echo $targetid; ?>;
var pid = $(targetid).attr('id');
var pid = '#'+pid;
var captionHeight = $(pid+' .caption').outerHeight(true);
var thumbHeight = <?php echo $thumb_height; ?> + captionHeight;
$(pid+' .fg').css({'max-width':'<?php echo $canvas_width; ?>px'});
$(pid+' .thumb').width(<?php echo $thumb_width; ?>);
$(pid+' .thumb').height(thumbHeight);
$(pid+' .thumb-itself').height(<?php echo $thumb_height; ?>);
var numThumbs = $(pid+' .thumbwrap').attr('title');
// number of thumbs to display per row
var thumbsPerRow = Math.ceil(numThumbs / <?php echo $num_rows; ?>);
// get slider width
var sliderWidth = thumbsPerRow * <?php echo $thumb_width_padded; ?>;
// must set slider width to enable horizontal scrolling
$(pid+' .thumbwrap-inner').css({'width':+sliderWidth+'px', 'height':'<?php echo $canvas_max_height; ?>px'});
// enable disable prev next buttons at startup
var newScrollLeft = $(pid+' .thumbwrap').scrollLeft();
if(newScrollLeft == 0) { $(pid+' .fgleft').hide(); }
if(sliderWidth - newScrollLeft == <?php echo $canvas_width; ?>) { $(pid+' .fgright').hide(); }
});
</script>