function wppa_load_footer()
{
    global $wpdb;
    global $wppa_session;
    echo '
		<!-- start WPPA+ Footer data -->
		';
    // Do they use our lightbox?
    if (wppa_opt('lightbox_name') == 'wppa') {
        $fontsize_lightbox = wppa_opt('fontsize_lightbox') ? wppa_opt('fontsize_lightbox') : '10';
        $d = wppa_switch('ovl_show_counter') ? 1 : 0;
        $ovlh = wppa_opt('ovl_txt_lines') == 'auto' ? 'auto' : (wppa_opt('ovl_txt_lines') + $d) * ($fontsize_lightbox + 2);
        $txtcol = wppa_opt('ovl_theme') == 'black' ? '#a7a7a7' : '#272727';
        $dark = wppa('is_mobile') ? '0.1' : '0.1';
        // The lightbox overlay background
        echo '<div' . ' id="wppa-overlay-bg"' . ' style="' . 'text-align:center;' . 'display:none;' . 'position:fixed;' . 'top:0;' . 'left:0;' . 'z-index:100090;' . 'width:100%;' . 'height:2048px;' . 'background-color:' . wppa_opt('ovl_bgcolor') . ';' . '"' . ' onclick="wppaOvlOnclick(event)"' . ' >';
        // Display legenda
        if (wppa_switch('ovl_show_legenda') && !wppa('is_mobile')) {
            echo '<div' . ' id="wppa-ovl-legenda-1"' . ' onmouseover="jQuery(this).css(\'visibility\',\'visible\');"' . ' onmouseout="jQuery(this).css(\'visibility\',\'hidden\');"' . ' style="' . 'position:absolute;' . 'left:0;' . 'top:0;' . 'background-color:' . wppa_opt('ovl_theme') . ';' . 'color:' . $txtcol . ';' . 'visibility:visible;' . '"' . ' >
					' . __('Press f for fullscreen.', 'wp-photo-album-plus') . '
				</div>';
        }
        // The 'exit' icon
        echo '<div' . ' id="wppa-exit-btn"' . ' style="height:48px;z-index:100098;position:fixed;top:0;right:0;opacity:0.75;"' . ' onclick="wppaOvlHide()"' . ' onmouseover="jQuery(this).stop().fadeTo(300,1);"' . ' onmouseout="jQuery(this).stop().fadeTo(300,' . $dark . ');"' . ' >' . wppa_get_svghtml('Exit', '48px', true, true, '0', '0', '0', '0') . '</div>' . '<script>' . 'jQuery(\'#wppa-exit-btn\').on(\'touchstart\',function(){jQuery(\'#wppa-exit-btn\').stop().fadeTo(300,1);});' . 'jQuery(\'#wppa-exit-btn\').on(\'touchend\',function(){jQuery(\'#wppa-exit-btn\').stop().fadeTo(300,' . $dark . ');});' . '</script>';
        // The 'fullscreen' icon
        echo '<div' . ' id="wppa-fulls-btn"' . ' style="height:48px;z-index:100092;position:fixed;top:0;right:48px;opacity:0.75;"' . ' onclick="wppaOvlFull()"' . ' onmouseover="jQuery(this).stop().fadeTo(300,1);"' . ' onmouseout="jQuery(this).stop().fadeTo(300,' . $dark . ');"' . ' >' . wppa_get_svghtml('Full-Screen', '48px', true, true, '0', '0', '0', '0') . '</div>' . '<script>' . 'jQuery(\'#wppa-fulls-btn\').on(\'touchstart\',function(){jQuery(\'#wppa-fulls-btn\').stop().fadeTo(300,1);});' . 'jQuery(\'#wppa-fulls-btn\').on(\'touchend\',function(){jQuery(\'#wppa-fulls-btn\').stop().fadeTo(300,' . $dark . ');});' . '</script>';
        // Close lightbox overlay background
        echo '</div>';
        // The Lightbox Image container
        echo '<div' . ' id="wppa-overlay-ic"' . ' style="' . 'position:fixed;' . 'top:50%;' . 'left:50%;' . 'z-index:100095;' . 'opacity:1;' . 'box-shadow:none;' . 'box-sizing:content-box;' . '"' . ' >' . '</div>';
        // The Spinner image
        echo '<img' . ' id="wppa-overlay-sp"' . ' alt="spinner"' . ' style="' . 'position:fixed;' . 'top:50%;' . 'margin-top:-16px;' . 'left:50%;' . 'margin-left:-16px;' . 'z-index:100100;' . 'opacity:1;' . 'visibility:hidden;' . 'box-shadow:none;' . '"' . ' src="' . wppa_get_imgdir() . 'loading.gif"' . ' />';
        // The init vars
        echo '
		<script type="text/javascript">
			jQuery("#wppa-overlay-bg").css({height:window.innerHeight});
			wppaOvlModeInitial = "' . (wppa('is_mobile') ? wppa_opt('ovl_mode_initial_mob') : wppa_opt('ovl_mode_initial')) . '";
			wppaOvlTxtHeight = "' . $ovlh . '";
			wppaOvlOpacity = ' . wppa_opt('ovl_opacity') / 100 . ';
			wppaOvlOnclickType = "' . wppa_opt('ovl_onclick') . '";
			wppaOvlTheme = "' . wppa_opt('ovl_theme') . '";
			wppaOvlAnimSpeed = ' . wppa_opt('ovl_anim') . ';
			wppaOvlSlideSpeed = ' . wppa_opt('ovl_slide') . ';
			wppaVer4WindowWidth = 800;
			wppaVer4WindowHeight = 600;
			wppaOvlShowCounter = ' . (wppa_switch('ovl_show_counter') ? 'true' : 'false') . ';
			' . (wppa_opt('fontfamily_lightbox') ? 'wppaOvlFontFamily = "' . wppa_opt('fontfamily_lightbox') . '"' : '') . '
			wppaOvlFontSize = "' . $fontsize_lightbox . '";
			' . (wppa_opt('fontcolor_lightbox') ? 'wppaOvlFontColor = "' . wppa_opt('fontcolor_lightbox') . '"' : '') . '
			' . (wppa_opt('fontweight_lightbox') ? 'wppaOvlFontWeight = "' . wppa_opt('fontweight_lightbox') . '"' : '') . '
			' . (wppa_opt('fontsize_lightbox') ? 'wppaOvlLineHeight = "' . (wppa_opt('fontsize_lightbox') + '2') . '"' : '') . '
			wppaOvlFullLegenda = "' . __('Keys: f = next mode; q,x = exit; p = previous, n = next, s = start/stop, d = dismiss this notice.', 'wp-photo-album-plus') . '";
			wppaOvlFullLegendaSingle = "' . __('Keys: f = next mode; q,x = exit; d = dismiss this notice.', 'wp-photo-album-plus') . '";
			wppaOvlVideoStart = ' . (wppa_switch('ovl_video_start') ? 'true' : 'false') . ';
			wppaOvlAudioStart = ' . (wppa_switch('ovl_audio_start') ? 'true' : 'false') . ';
			wppaOvlShowLegenda = ' . (wppa_switch('ovl_show_legenda') && !wppa('is_mobile') ? 'true' : 'false') . ';
			wppaOvlShowStartStop = ' . (wppa_switch('ovl_show_startstop') ? 'true' : 'false') . ';
			wppaToggleFullScreen = "' . __('Toggle fullscreen', 'wp-photo-album-plus') . '";
			wppaIsMobile = ' . (wppa_is_mobile() ? 'true' : 'false') . ';
		</script>
		';
    }
    // The photo views cache
    echo '
	<script type="text/javascript">';
    if (isset($wppa_session['photo'])) {
        foreach (array_keys($wppa_session['photo']) as $p) {
            echo '
				wppaPhotoView[' . $p . '] = true;';
        }
    }
    echo '
	</script>
<!-- end WPPA+ Footer data -->
';
    // Debugging, show queries
    wppa_dbg_cachecounts('print');
    // Debugging, show active plugins
    if (wppa('debug')) {
        $plugins = get_option('active_plugins');
        wppa_dbg_msg('Active Plugins');
        foreach ($plugins as $plugin) {
            wppa_dbg_msg($plugin);
        }
        wppa_dbg_msg('End Active Plugins');
    }
    echo '
<!-- Nonce for various wppa actions -->';
    // Nonce field for Ajax bump view counter from lightbox, and rating
    wp_nonce_field('wppa-check', 'wppa-nonce', false, true);
    echo '
<!-- Do user upload -->';
    // Do the upload if required and not yet done
    wppa_user_upload();
    // Done
    echo '
<!-- Done user upload -->';
}
function wppa_initialize_runtime($force = false)
{
    global $wppa;
    global $wppa_opt;
    global $wppa_revno;
    global $wppa_api_version;
    global $wpdb;
    global $wppa_initruntimetime;
    global $wppa_defaults;
    $wppa_initruntimetime = -microtime(true);
    if ($force) {
        $wppa = false;
        // destroy existing arrays
        $wppa_opt = false;
        delete_option('wppa_cached_options');
    }
    if (is_array($wppa) && !$force) {
        return;
        // Done already
    }
    if (!is_array($wppa)) {
        $wppa = array('debug' => false, 'revno' => $wppa_revno, 'api_version' => $wppa_api_version, 'fullsize' => '', 'enlarge' => false, 'occur' => '0', 'mocc' => '0', 'widget_occur' => '0', 'in_widget' => false, 'is_cover' => '0', 'is_slide' => '0', 'is_slideonly' => '0', 'is_slideonlyf' => '0', 'is_filmonly' => '0', 'film_on' => '0', 'browse_on' => '0', 'name_on' => '0', 'desc_on' => '0', 'numbar_on' => '0', 'single_photo' => '', 'is_mphoto' => '0', 'start_album' => '', 'align' => '', 'src' => false, 'portrait_only' => false, 'in_widget_linkurl' => '', 'in_widget_linktitle' => '', 'in_widget_timeout' => '0', 'ss_widget_valign' => '', 'album_count' => '0', 'thumb_count' => '0', 'out' => '', 'auto_colwidth' => false, 'permalink' => '', 'rendering_enabled' => false, 'tabcount' => '0', 'comment_id' => '', 'comment_photo' => '0', 'comment_user' => '', 'comment_email' => '', 'comment_text' => '', 'no_default' => false, 'in_widget_frame_height' => '', 'in_widget_frame_width' => '', 'user_uploaded' => false, 'current_album' => '0', 'searchstring' => wppa_test_for_search(), 'searchresults' => '', 'any' => false, 'ajax' => false, 'error' => false, 'iptc' => false, 'exif' => false, 'is_topten' => false, 'topten_count' => '0', 'is_lasten' => false, 'lasten_count' => '0', 'is_featen' => false, 'featen_count' => '0', 'start_photo' => '0', 'is_single' => false, 'is_landing' => '0', 'is_comten' => false, 'comten_count' => '0', 'is_tag' => false, 'photos_only' => false, 'albums_only' => false, 'page' => '', 'geo' => '', 'continue' => '', 'is_upload' => false, 'ajax_import_files' => false, 'ajax_import_files_done' => false, 'ajax_import_files_error' => '', 'last_albums' => false, 'last_albums_parent' => '0', 'is_multitagbox' => false, 'is_tagcloudbox' => false, 'taglist' => '', 'tagcols' => '2', 'is_related' => false, 'related_count' => '0', 'is_owner' => '', 'is_upldr' => '', 'no_esc' => false, 'front_edit' => false, 'is_autopage' => false, 'is_cat' => false, 'bestof' => false, 'is_subsearch' => false, 'is_rootsearch' => false, 'is_superviewbox' => false, 'is_searchbox' => false, 'may_sub' => false, 'may_root' => false, 'links_no_page' => array('none', 'file', 'lightbox', 'lightboxsingle', 'fullpopup'), 'shortcode_content' => '', 'is_remote' => false, 'is_supersearch' => false, 'supersearch' => '', 'is_mobile' => wppa_is_mobile(), 'rel' => get_option('wppa_lightbox_name') == 'wppa' ? 'data-rel' : 'rel', 'lbtitle' => get_option('wppa_lightbox_name') == 'wppa' ? 'data-lbtitle' : 'title', 'alt' => 'even');
    }
    $wppa_opt = get_option('wppa_cached_options', false);
    if (!is_array($wppa_opt)) {
        wppa_set_defaults();
        $wppa_opt = $wppa_defaults;
        foreach (array_keys($wppa_opt) as $option) {
            $optval = get_option($option, 'nil');
            if ($optval !== 'nil') {
                $wppa_opt[$option] = $optval;
            }
        }
        update_option('wppa_cached_options', $wppa_opt);
    }
    if (isset($_GET['debug']) && wppa_switch('wppa_allow_debug')) {
        $key = $_GET['debug'] ? $_GET['debug'] : E_ALL;
        $wppa['debug'] = $key;
    }
    wppa_load_language();
    // Delete obsolete spam
    $spammaxage = wppa_opt('wppa_spam_maxage');
    if ($spammaxage != 'none') {
        $time = time();
        $obsolete = $time - $spammaxage;
        $iret = $wpdb->query($wpdb->prepare("DELETE FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'spam' AND `timestamp` < %s", $obsolete));
        if ($iret) {
            wppa_update_option('wppa_spam_auto_delcount', get_option('wppa_spam_auto_delcount', '0') + $iret);
        }
    }
    // Create an album if required
    if (wppa_switch('wppa_grant_an_album') && wppa_switch('wppa_owner_only') && is_user_logged_in() && (current_user_can('wppa_upload') || wppa_switch('wppa_user_upload_on'))) {
        $owner = wppa_get_user('login');
        $user = wppa_get_user(wppa_opt('wppa_grant_name'));
        $albs = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `owner` = %s", $owner));
        if (!$albs) {
            // make an album for this user
            $name = $user;
            if (is_admin()) {
                $desc = __('Default photo album for', 'wppa') . ' ' . $user;
            } else {
                $desc = __a('Default photo album for') . ' ' . $user;
            }
            $parent = wppa_opt('wppa_grant_parent');
            $id = wppa_create_album_entry(array('name' => $name, 'description' => $desc, 'a_parent' => $parent));
            wppa_flush_treecounts($parent);
            wppa_index_add('album', $id);
        }
    }
    $wppa_initruntimetime += microtime(true);
}
function wppa_reset_occurrance()
{
    global $wppa;
    global $wppa_revno;
    global $wppa_api_version;
    global $thumbs;
    $thumbs = false;
    wppa_cache_thumb('invalidate');
    wppa_cache_album('invalidate');
    $mocc = isset($wppa['mocc']) ? $wppa['mocc'] : '0';
    $occ = isset($wppa['occur']) ? $wppa['occur'] : '0';
    $wocc = isset($wppa['widget_occur']) ? $wppa['widget_occur'] : '0';
    $rend = isset($wppa['rendering_enabled']) ? $wppa['rendering_enabled'] : false;
    $debug = isset($wppa['debug']) ? $wppa['debug'] : false;
    $wppa = array('debug' => $debug, 'revno' => $wppa_revno, 'api_version' => $wppa_api_version, 'fullsize' => '', 'enlarge' => false, 'occur' => $occ, 'mocc' => $mocc, 'widget_occur' => $wocc, 'in_widget' => false, 'is_cover' => '0', 'is_slide' => '0', 'is_slideonly' => '0', 'is_slideonlyf' => '0', 'is_filmonly' => '0', 'film_on' => '0', 'browse_on' => '0', 'name_on' => '0', 'desc_on' => '0', 'numbar_on' => '0', 'single_photo' => '', 'is_mphoto' => '0', 'is_xphoto' => '0', 'start_album' => '', 'align' => '', 'src' => false, 'portrait_only' => false, 'in_widget_linkurl' => '', 'in_widget_linktitle' => '', 'in_widget_timeout' => '0', 'ss_widget_valign' => '', 'album_count' => '0', 'thumb_count' => '0', 'out' => '', 'auto_colwidth' => false, 'permalink' => '', 'rendering_enabled' => $rend, 'tabcount' => '0', 'comment_id' => '', 'comment_photo' => '0', 'comment_user' => '', 'comment_email' => '', 'comment_text' => '', 'no_default' => false, 'in_widget_frame_height' => '', 'in_widget_frame_width' => '', 'current_album' => '0', 'searchstring' => wppa_test_for_search(), 'searchresults' => '', 'any' => false, 'ajax' => false, 'error' => false, 'iptc' => false, 'exif' => false, 'is_topten' => false, 'topten_count' => '0', 'is_lasten' => false, 'lasten_count' => '0', 'is_featen' => false, 'featen_count' => '0', 'start_photo' => '0', 'is_single' => false, 'is_landing' => '0', 'is_comten' => false, 'comten_count' => '0', 'is_tag' => false, 'photos_only' => false, 'albums_only' => false, 'medals_only' => false, 'page' => '', 'geo' => '', 'continue' => '', 'is_upload' => false, 'ajax_import_files' => false, 'ajax_import_files_done' => false, 'ajax_import_files_error' => '', 'last_albums' => false, 'last_albums_parent' => '0', 'is_multitagbox' => false, 'is_tagcloudbox' => false, 'taglist' => '', 'tagcols' => '2', 'is_related' => false, 'related_count' => '0', 'is_owner' => '', 'is_upldr' => '', 'no_esc' => false, 'front_edit' => false, 'is_autopage' => false, 'is_cat' => false, 'bestof' => false, 'is_subsearch' => false, 'is_rootsearch' => false, 'is_superviewbox' => false, 'is_searchbox' => false, 'may_sub' => false, 'may_root' => false, 'links_no_page' => array('none', 'file', 'lightbox', 'lightboxsingle', 'fullpopup'), 'shortcode_content' => '', 'is_remote' => false, 'is_supersearch' => false, 'supersearch' => '', 'is_mobile' => wppa_is_mobile(), 'rel' => get_option('wppa_lightbox_name') == 'wppa' ? 'data-rel' : 'rel', 'lbtitle' => get_option('wppa_lightbox_name') == 'wppa' ? 'data-lbtitle' : 'title', 'alt' => 'even', 'is_wppa_tree' => false, 'is_calendar' => false, 'calendar' => '', 'caldate' => '', 'calendarall' => false, 'reverse' => false, 'current_photo' => false, 'is_stereobox' => false, 'npages' => '', 'curpage' => '', 'ss_pag' => false, 'slideframewidth' => '', 'slideframeheight' => '', 'ajax_import_files_error' => '', 'src_script' => '', 'is_url' => false, 'is_inverse' => false, 'coverphoto_pos' => '', 'forceroot' => '', 'landingpage' => '', 'is_admins_choice' => false, 'admins_choice_users' => '', 'for_sm' => false, 'max_width' => false);
}
function wppa_get_cover_width($type, $numeric = false)
{
    $conwidth = wppa_get_container_width();
    $cols = wppa_get_cover_cols($type);
    $ppc = floor('100' / $cols);
    if (wppa_is_mobile()) {
        $result = 'width:100%;';
    } elseif (wppa_is_responsive()) {
        $result = 'width:' . $ppc . '%;';
    } else {
        $result = 'width:' . floor(($conwidth - 8 * ($cols - 1)) / $cols) . 'px;';
    }
    if ($numeric) {
        $result = str_replace('width:', '', $result);
        if (strpos($result, '%')) {
            $result = $result * wppa_opt('initial_colwidth') / '100';
        } else {
            $result = str_replace('px;', '', $result);
        }
    }
    return $result;
}
function wppa_get_picture_html($args)
{
    // Init
    $defaults = array('id' => '0', 'type' => '', 'class' => '');
    $args = wp_parse_args($args, $defaults);
    $id = strval(intval($args['id']));
    $type = $args['type'];
    $class = $args['class'];
    // Check existance of required args
    foreach (array('id', 'type') as $item) {
        if (!$args[$item]) {
            wppa_dbg_msg('Missing ' . $item . ' in call to wppa_get_picture_html()', 'red', 'force');
            return false;
        }
    }
    // Check validity of args
    if (!wppa_photo_exists($id)) {
        wppa_dbg_msg('Photo ' . $id . ' does not exist in call to wppa_get_picture_html(). Type = ' . $type, 'red', 'force');
        return false;
    }
    $types = array('sphoto', 'mphoto', 'xphoto', 'cover', 'thumb', 'ttthumb', 'comthumb', 'fthumb', 'twthumb', 'ltthumb', 'albthumb');
    if (!in_array($type, $types)) {
        wppa_dbg_msg('Unimplemented type ' . $type . ' in call to wppa_get_picture_html()', 'red', 'force');
        return false;
    }
    // Get other data
    $link = wppa_get_imglnk_a($type, $id);
    $isthumb = strpos($type, 'thumb') !== false;
    $file = wppa_fix_poster_ext($isthumb ? wppa_get_thumb_path($id) : wppa_get_photo_path($id), $id);
    $href = wppa_fix_poster_ext($isthumb ? wppa_get_thumb_url($id) : wppa_get_photo_url($id), $id);
    $autocol = wppa('auto_colwidth') || wppa('fullsize') > 0 && wppa('fullsize') <= 1.0;
    $title = $link ? esc_attr($link['title']) : esc_attr(stripslashes(wppa_get_photo_name($id)));
    $alt = wppa_get_imgalt($id);
    // Find image style
    switch ($type) {
        case 'sphoto':
            $style = 'width:100%;margin:0;';
            if (!wppa_in_widget()) {
                switch (wppa_opt('fullimage_border_width')) {
                    case '':
                        $style .= 'padding:0;' . 'border:none;';
                        break;
                    case '0':
                        $style .= 'padding:0;' . 'border:1px solid ' . wppa_opt('bcolor_fullimg') . ';' . 'box-sizing:border-box;';
                        break;
                    default:
                        $style .= 'padding:' . (wppa_opt('fullimage_border_width') - '1') . 'px;' . 'border:1px solid ' . wppa_opt('bcolor_fullimg') . ';' . 'box-sizing:border-box;' . 'background-color:' . wppa_opt('bgcolor_fullimg') . ';';
                        // If we do round corners...
                        if (wppa_opt('bradius') > '0') {
                            // then also here
                            $style .= 'border-radius:' . wppa_opt('fullimage_border_width') . 'px;';
                        }
                }
            }
            break;
        case 'mphoto':
        case 'xphoto':
            $style = 'width:100%;margin:0;padding:0;border:none;';
            break;
        default:
            wppa_dbg_msg('Style for type ' . $type . ' is not implemented yet in wppa_get_picture_html()', 'red', 'force');
            return false;
    }
    if ($link['is_lightbox']) {
        $style .= 'cursor:url( ' . wppa_get_imgdir() . wppa_opt('magnifier') . ' ),pointer;';
        $title = wppa_zoom_in($id);
    }
    // Create the html
    $result = '';
    // The link
    if ($link) {
        // Link is lightbox
        if ($link['is_lightbox']) {
            $lbtitle = wppa_get_lbtitle($type, $id);
            $videobody = esc_attr(wppa_get_video_body($id));
            $audiobody = esc_attr(wppa_get_audio_body($id));
            $videox = wppa_get_videox($id);
            $videoy = wppa_get_videoy($id);
            $result .= '<a' . ' href="' . $link['url'] . '"' . ($lbtitle ? ' ' . wppa('lbtitle') . '="' . $lbtitle . '"' : '') . ($videobody ? ' data-videohtml="' . $videobody . '"' : '') . ($audiobody ? ' data-audiohtml="' . $audiobody . '"' : '') . ($videox ? ' data-videonatwidth="' . $videox . '"' : '') . ($videoy ? ' data-videonatheight="' . $videoy . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '"' . ($link['target'] ? ' target="' . $link['target'] . '"' : '') . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' data-alt="' . esc_attr(wppa_get_imgalt($id, true)) . '"' . ' >';
        } else {
            $result .= '<a' . (wppa_is_mobile() ? ' ontouchstart="wppaStartTime();" ontouchend="wppaTapLink(\'' . $id . '\',\'' . $link['url'] . '\');" ' : ' onclick="_bumpClickCount( \'' . $id . '\' );window.open(\'' . $link['url'] . '\', \'' . $link['target'] . '\' )"') . ' title="' . $link['title'] . '"' . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' >';
        }
    }
    // The image
    // Video?
    if (wppa_is_video($id)) {
        $result .= wppa_get_video_html(array('id' => $id, 'controls' => !$link, 'style' => $style, 'class' => $class));
    } else {
        $result .= '<img' . ' id="ph-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $href . '"' . ' ' . wppa_get_imgalt($id) . ($class ? ' class="' . $class . '" ' : '') . ($title ? ' title="' . $title . '" ' : '') . ' style="' . $style . '"' . ' />';
    }
    // Close the link
    if ($link) {
        $result .= '</a>';
    }
    // Add audio?			sphoto
    if (wppa_has_audio($id)) {
        $result .= '<div style="position:relative;z-index:11;" >';
        // Find style for audio controls
        switch ($type) {
            case 'sphoto':
                $pad = wppa_opt('fullimage_border_width') === '' ? 0 : wppa_opt('fullimage_border_width') + 1;
                $bot = wppa_opt('fullimage_border_width') === '' ? 0 : wppa_opt('fullimage_border_width') - 1;
                $style = 'margin:0;' . 'padding:0 ' . $pad . 'px;' . 'bottom:' . $bot . 'px;';
                $class = 'size-medium wppa-sphoto wppa-sphoto-' . wppa('mocc');
                break;
            case 'mphoto':
            case 'xphoto':
                $style = 'margin:0;' . 'padding:0;' . 'bottom:0;';
                $class = 'size-medium wppa-' . $type . ' wppa-' . $type . '-' . wppa('mocc');
                break;
            default:
                $style = 'margin:0;' . 'padding:0;';
                $class = '';
        }
        // Get the html for audio
        $result .= wppa_get_audio_html(array('id' => $id, 'cursor' => 'cursor:pointer;', 'style' => $style . 'position:absolute;' . 'box-sizing:border-box;' . 'width:100%;' . 'border:none;' . 'height:' . wppa_get_audio_control_height() . 'px;' . 'border-radius:0;', 'class' => $class));
        $result .= '</div>';
    }
    // Update statistics
    if (!wppa_in_widget()) {
        wppa_bump_viewcount('photo', $id);
    }
    // Done !
    return $result;
}