<?php
    switch ( $attachment['mimeType'] ) :
        case 'image/jpeg' :
        case 'image/png'  :
            $baseSrc  = URL_ATTACHMENTS;
            $basePath = PATH_ATTACHMENTS;

            $link = "$baseSrc/$attachment[pathname]";
            $src  =  $link;
            if ( file_exists("$basePath/small/$attachment[pathname]") ) {
                $src  = "$baseSrc/small/$attachment[pathname]";
            }
?>
            <a href="<?php echo $link; ?>" target="_blank">
                <img 
                    data-src="<?php echo $src; ?>" 
                    alt="<?php echo $userProject['title'] ?>" 
                    class="img-fluid img-thumbnail lazy mb-3"
                >
            </a>
<?php
            
            break;
        case 'application/pdf' :
?> 
            <div class="col text-center">
                <a href="<?php echo URL_ASSETS; ?>/images/attachments/<?php echo $attachment['pathname']; ?>" target="_blank"><img src="<?php echo URL_ASSETS; ?>/images/pdf-icon.png" style="width:50px;height:51px;"/></a>
                <br>
                <a href="<?php echo URL_ASSETS; ?>/images/attachments/<?php echo $attachment['pathname']; ?>" target="_blank">View PDF</a>
            </div>
<?php
            break;
        case 'video/quicktime' :
        case 'video/mp4' :
?>
            <div class="col">
                <video width="100%" controls class="img-thumbnail">
                    <source src="<?php echo URL_ASSETS; ?>/images/attachments/<?php echo $attachment['pathname']; ?>" type="video/mp4">
                </video>
            </div>
<?php
            break;
    endswitch;
?>