function wppa_create_thumbnail($id, $use_source = true)
{
    // Find file to make thumbnail from
    $source_path = wppa_fix_poster_ext(wppa_get_source_path($id), $id);
    // Use source if requested and available
    if ($use_source) {
        if (!wppa_switch('watermark_thumbs') && is_file($source_path)) {
            $file = $source_path;
            // Use sourcefile
        } else {
            $file = wppa_fix_poster_ext(wppa_get_photo_path($id), $id);
            // Use photofile
        }
        // Non standard orientation files: never use source
        $orient = wppa_get_exif_orientation($file);
        if ($orient > '1') {
            $file = wppa_fix_poster_ext(wppa_get_photo_path($id), $id);
            // Use photofile
        }
    } else {
        $file = wppa_fix_poster_ext(wppa_get_photo_path($id), $id);
        // Use photofile
    }
    // Max side
    $max_side = wppa_get_minisize();
    // Check file
    if (!file_exists($file)) {
        return false;
    }
    // No file, fail
    $img_attr = getimagesize($file);
    if (!$img_attr) {
        return false;
    }
    // Not an image, fail
    // Retrieve aspect
    $asp_attr = explode(':', wppa_opt('thumb_aspect'));
    // Get output path
    $thumbpath = wppa_get_thumb_path($id);
    if (wppa_get_ext($thumbpath) == 'xxx') {
        // Video poster
        $thumbpath = wppa_strip_ext($thumbpath) . '.jpg';
    }
    // Source size
    $src_size_w = $img_attr[0];
    $src_size_h = $img_attr[1];
    // Temp convert width if stereo
    if (wppa_get_photo_item($id, 'stereo')) {
        $src_size_w /= 2;
    }
    // Mime type and thumb type
    $mime = $img_attr[2];
    $type = $asp_attr[2];
    // Source native aspect
    $src_asp = $src_size_h / $src_size_w;
    // Required aspect
    if ($type == 'none') {
        $dst_asp = $src_asp;
    } else {
        $dst_asp = $asp_attr[0] / $asp_attr[1];
    }
    // Convert back width if stereo
    if (wppa_get_photo_item($id, 'stereo')) {
        $src_size_w *= 2;
    }
    // Create the source image
    switch ($mime) {
        // mime type
        case 1:
            // gif
            $temp = @imagecreatefromgif($file);
            if ($temp) {
                $src = imagecreatetruecolor($src_size_w, $src_size_h);
                imagecopy($src, $temp, 0, 0, 0, 0, $src_size_w, $src_size_h);
                imagedestroy($temp);
            } else {
                $src = false;
            }
            break;
        case 2:
            // jpeg
            if (!function_exists('wppa_imagecreatefromjpeg')) {
                wppa_log('Error', 'Function wppa_imagecreatefromjpeg does not exist.');
            }
            $src = @wppa_imagecreatefromjpeg($file);
            break;
        case 3:
            // png
            $src = @imagecreatefrompng($file);
            break;
    }
    if (!$src) {
        wppa_log('Error', 'Image file ' . $file . ' is corrupt while creating thmbnail');
        return true;
    }
    // Compute the destination image size
    if ($dst_asp < 1.0) {
        // Landscape
        $dst_size_w = $max_side;
        $dst_size_h = round($max_side * $dst_asp);
    } else {
        // Portrait
        $dst_size_w = round($max_side / $dst_asp);
        $dst_size_h = $max_side;
    }
    // Create the ( empty ) destination image
    $dst = imagecreatetruecolor($dst_size_w, $dst_size_h);
    if ($mime == 3) {
        // Png, save transparancy
        imagealphablending($dst, false);
        imagesavealpha($dst, true);
    }
    // Fill with the required color
    $c = trim(strtolower(wppa_opt('bgcolor_thumbnail')));
    if ($c != '#000000') {
        $r = hexdec(substr($c, 1, 2));
        $g = hexdec(substr($c, 3, 2));
        $b = hexdec(substr($c, 5, 2));
        $color = imagecolorallocate($dst, $r, $g, $b);
        if ($color === false) {
            wppa_log('Err', 'Unable to set background color to: ' . $r . ', ' . $g . ', ' . $b . ' in wppa_create_thumbnail');
        } else {
            imagefilledrectangle($dst, 0, 0, $dst_size_w, $dst_size_h, $color);
        }
    }
    // Switch on what we have to do
    switch ($type) {
        case 'none':
            // Use aspect from fullsize image
            $src_x = 0;
            $src_y = 0;
            $src_w = $src_size_w;
            $src_h = $src_size_h;
            $dst_x = 0;
            $dst_y = 0;
            $dst_w = $dst_size_w;
            $dst_h = $dst_size_h;
            break;
        case 'clip':
            // Clip image to given aspect ratio
            if ($src_asp < $dst_asp) {
                // Source image more landscape than destination
                $dst_x = 0;
                $dst_y = 0;
                $dst_w = $dst_size_w;
                $dst_h = $dst_size_h;
                $src_x = round(($src_size_w - $src_size_h / $dst_asp) / 2);
                $src_y = 0;
                $src_w = round($src_size_h / $dst_asp);
                $src_h = $src_size_h;
            } else {
                $dst_x = 0;
                $dst_y = 0;
                $dst_w = $dst_size_w;
                $dst_h = $dst_size_h;
                $src_x = 0;
                $src_y = round(($src_size_h - $src_size_w * $dst_asp) / 2);
                $src_w = $src_size_w;
                $src_h = round($src_size_w * $dst_asp);
            }
            break;
        case 'padd':
            // Padd image to given aspect ratio
            if ($src_asp < $dst_asp) {
                // Source image more landscape than destination
                $dst_x = 0;
                $dst_y = round(($dst_size_h - $dst_size_w * $src_asp) / 2);
                $dst_w = $dst_size_w;
                $dst_h = round($dst_size_w * $src_asp);
                $src_x = 0;
                $src_y = 0;
                $src_w = $src_size_w;
                $src_h = $src_size_h;
            } else {
                $dst_x = round(($dst_size_w - $dst_size_h / $src_asp) / 2);
                $dst_y = 0;
                $dst_w = round($dst_size_h / $src_asp);
                $dst_h = $dst_size_h;
                $src_x = 0;
                $src_y = 0;
                $src_w = $src_size_w;
                $src_h = $src_size_h;
            }
            break;
        default:
            // Not implemented
            return false;
    }
    // Copy left half if stereo
    if (wppa_get_photo_item($id, 'stereo')) {
        $src_w /= 2;
    }
    // Do the copy
    imagecopyresampled($dst, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
    // Save the thumb
    $thumbpath = wppa_strip_ext($thumbpath);
    switch ($mime) {
        // mime type
        case 1:
            $full_thumbpath = $thumbpath . '.gif';
            imagegif($dst, $full_thumbpath);
            break;
        case 2:
            $full_thumbpath = $thumbpath . '.jpg';
            imagejpeg($dst, $full_thumbpath, wppa_opt('jpeg_quality'));
            break;
        case 3:
            $full_thumbpath = $thumbpath . '.png';
            imagepng($dst, $full_thumbpath, 6);
            break;
    }
    // Cleanup
    imagedestroy($src);
    imagedestroy($dst);
    // Make sure file is accessable
    wppa_chmod($full_thumbpath);
    // Optimize
    wppa_optimize_image_file($full_thumbpath);
    // Compute and save sizes
    wppa_get_thumbx($id, 'force');
    // forces recalc x and y
    return true;
}
Exemplo n.º 2
0
function wppa_theme()
{
    global $wppa_version;
    $wppa_version = '6-1-15-000';
    // The version number of this file
    global $wppa;
    global $wppa_show_statistics;
    // Can be set to true by a custom page template
    $curpage = wppa_get_curpage();
    // Get the page # we are on when pagination is on, or 1
    $didsome = false;
    // Required initializations for pagination
    $n_album_pages = '0';
    // "
    $n_thumb_pages = '0';
    // "
    // Open container
    wppa_container('open');
    // Show statistics if set so by the page template
    if ($wppa_show_statistics) {
        wppa_statistics();
    }
    // Display breadcrumb navigation only if it is set in the settings page
    wppa_breadcrumb('optional');
    if (wppa_page('albums')) {
        // Page 'Albums' requested
        // Get the albums and the thumbs and the number of pages for each set
        $albums = wppa_get_albums();
        // Get the albums
        $n_album_pages = wppa_get_npages('albums', $albums);
        // Get the number of album pages
        if (wppa_opt('thumbtype') != 'none') {
            $thumbs = wppa_get_thumbs();
            // Get the Thumbs
        } else {
            $thumbs = false;
        }
        $wanted_empty = wppa_is_wanted_empty($thumbs);
        // See if we need to display an empty thumbnail area
        $n_thumb_pages = wppa_get_npages('thumbs', $thumbs);
        // Get the number of thumb pages
        if ($n_thumb_pages == '0' && !$wanted_empty) {
            $thumbs = false;
        }
        // No pages: no thumbs. Maybe want covers only
        if ($wanted_empty) {
            $n_thumb_pages = '1';
        }
        // Get total number of pages
        if (!wppa_is_pagination()) {
            $totpag = '1';
        } else {
            $totpag = $n_album_pages + $n_thumb_pages;
        }
        // Make pagelinkbar if requested on top
        if (wppa_opt('pagelink_pos') == 'top' || wppa_opt('pagelink_pos') == 'both') {
            wppa_page_links($totpag, $curpage);
        }
        // Process the albums
        if (!wppa_switch('wppa_thumbs_first')) {
            if ($albums) {
                $counter_albums = '0';
                wppa_album_list('open');
                // Open Albums sub-container
                foreach ($albums as $album) {
                    // Loop the albums
                    $counter_albums++;
                    if (wppa_onpage('albums', $counter_albums, $curpage)) {
                        wppa_album_cover($album['id']);
                        // Show the cover
                        $didsome = true;
                    }
                    // End if on page
                }
                wppa_album_list('close');
                // Close Albums sub-container
            }
            // If albums
        }
        if ($didsome && wppa_is_pagination()) {
            $thumbs = false;
        }
        // Pag on and didsome: force a pagebreak by faking no thumbs
        if (count($thumbs) <= wppa_get_mincount() && !$wanted_empty) {
            $thumbs = false;
        }
        // Less than treshold value
        if (wppa_switch('wppa_thumbs_first') && $curpage > $n_thumb_pages) {
            $thumbs = false;
        }
        // If thumbs done, do not display an empty thumbarea
        // Process the thumbs
        if ($thumbs || $wanted_empty) {
            if (!$wanted_empty || !wppa_switch('thumbs_first') || wppa_get_curpage() == '1') {
                if (!$wanted_empty || wppa_switch('thumbs_first') || wppa_get_curpage() == $totpag) {
                    // Init
                    $counter_thumbs = '0';
                    // As covers
                    if (wppa_opt('wppa_thumbtype') == 'ascovers' || wppa_opt('wppa_thumbtype') == 'ascovers-mcr') {
                        // Do the thumbs As covers
                        wppa_thumb_list('open');
                        // Open Thumblist sub-container
                        $relpage = wppa_switch('wppa_thumbs_first') ? $curpage : $curpage - $n_album_pages;
                        foreach ($thumbs as $tt) {
                            global $thumb;
                            $thumb = $tt;
                            // Loop the Thumbs
                            $counter_thumbs++;
                            if (wppa_onpage('thumbs', $counter_thumbs, $relpage)) {
                                $didsome = true;
                                wppa_thumb_ascover($thumb['id']);
                                // Show Thumb as cover
                            }
                            // End if on page
                        }
                        wppa_thumb_list('close');
                        // Close Thumblist sub-container
                    } elseif (wppa_opt('wppa_thumbtype') == 'masonry-v') {
                        // Masonry
                        // The header
                        wppa_thumb_area('open');
                        // Open Thumbarea sub-container
                        wppa_popup();
                        // Prepare Popup box
                        wppa_album_name('top');
                        // Optionally display album name
                        wppa_album_desc('top');
                        // Optionally display album description
                        // Init
                        $relpage = wppa_switch('wppa_thumbs_first') ? $curpage : $curpage - $n_album_pages;
                        $cont_width = wppa_get_container_width();
                        $count_cols = ceil($cont_width / (wppa_opt('wppa_thumbsize') + wppa_opt('wppa_tn_margin')));
                        $correction = wppa_opt('wppa_tn_margin') * ($cont_width / $count_cols) / 100;
                        // Init the table
                        wppa_out('<table class="wppa-masonry" style="margin-top:3px;" ><tbody class="wppa-masonry" ><tr class="wppa-masonry" >');
                        // Init the columns
                        $col_headers = array();
                        $col_contents = array();
                        $col_heights = array();
                        $col_widths = array();
                        for ($col = 0; $col < $count_cols; $col++) {
                            $col_headers[$col] = '';
                            $col_contents[$col] = '';
                            $col_heights[$col] = 0;
                            $col_widths[$col] = 100;
                        }
                        // Process the thumbnails
                        $col = '0';
                        if ($thumbs) {
                            foreach ($thumbs as $tt) {
                                $id = $tt['id'];
                                $counter_thumbs++;
                                if (wppa_onpage('thumbs', $counter_thumbs, $relpage)) {
                                    $col_contents[$col] .= wppa_get_thumb_masonry($id);
                                    $col_heights[$col] += ($correction + wppa_get_thumby($id)) / ($correction + wppa_get_thumbx($id)) * $col_widths[$col];
                                    $col += '1';
                                    if ($col == $count_cols) {
                                        $col = '0';
                                    }
                                    $didsome = true;
                                }
                            }
                        }
                        // Find longest column
                        $long = 0;
                        for ($col = 0; $col < $count_cols; $col++) {
                            if ($col_heights[$col] > $long) {
                                $long = $col_heights[$col];
                            }
                        }
                        // Adjust column widths to resize lengths to equal lengths
                        for ($col = 0; $col < $count_cols; $col++) {
                            if ($col_heights[$col]) {
                                $col_widths[$col] = $long / $col_heights[$col] * $col_widths[$col];
                            }
                        }
                        // Adjust column widths to total 100
                        $wide = 0;
                        for ($col = 0; $col < $count_cols; $col++) {
                            $wide += $col_widths[$col];
                        }
                        for ($col = 0; $col < $count_cols; $col++) {
                            $col_widths[$col] = $col_widths[$col] * 100 / $wide;
                        }
                        // Make column headers
                        for ($col = 0; $col < $count_cols; $col++) {
                            $col_headers[$col] = '<td style="width: ' . $col_widths[$col] . '%; vertical-align:top;" class="wppa-masonry" >';
                        }
                        // Add the columns to the output stream
                        for ($col = 0; $col < $count_cols; $col++) {
                            wppa_out($col_headers[$col]);
                            wppa_out($col_contents[$col]);
                            wppa_out('</td>');
                        }
                        // Close the table
                        wppa_out('</tr></tbody></table>');
                        // The footer
                        wppa_album_name('bottom');
                        // Optionally display album name
                        wppa_album_desc('bottom');
                        // Optionally display album description
                        wppa_thumb_area('close');
                        // Close Thumbarea sub-container
                    } elseif (wppa_opt('wppa_thumbtype') == 'masonry-h') {
                        // Masonry
                        // The header
                        wppa_thumb_area('open');
                        // Open Thumbarea sub-container
                        wppa_popup();
                        // Prepare Popup box
                        wppa_album_name('top');
                        // Optionally display album name
                        wppa_album_desc('top');
                        // Optionally display album description
                        // Init
                        $relpage = wppa_switch('wppa_thumbs_first') ? $curpage : $curpage - $n_album_pages;
                        $cont_width = wppa_get_container_width('netto');
                        $correction = wppa_opt('wppa_tn_margin');
                        // Init the table
                        wppa_out('<table class="wppa-masonry" style="margin-top:3px;" ><tbody class="wppa-masonry" >');
                        // Process the thumbnails
                        $row_content = '';
                        $row_width = 0;
                        $target_row_height = wppa_opt('wppa_thumbsize') * 0.75 + $correction;
                        $rw_count = 0;
                        $tr_count = '1';
                        $done_count = 0;
                        $last = false;
                        $max_row_height = $target_row_height * 0.8;
                        // Init keep track for last
                        if ($thumbs) {
                            foreach ($thumbs as $tt) {
                                $id = $tt['id'];
                                $counter_thumbs++;
                                if (wppa_onpage('thumbs', $counter_thumbs, $relpage)) {
                                    $row_content .= wppa_get_thumb_masonry($tt['id']);
                                    $rw_count += 1;
                                    $row_width += wppa_get_thumbratioxy($id) * ($target_row_height - $correction);
                                    $didsome = true;
                                }
                                $done_count += 1;
                                $last = $done_count == count($thumbs);
                                if ($row_width > $cont_width || $last) {
                                    $tot_marg = $rw_count * $correction;
                                    $row_height = $row_width ? ($target_row_height - $correction) * ($cont_width - '3' - $tot_marg) / $row_width + $correction : '0';
                                    if (!$last) {
                                        $max_row_height = max($max_row_height, $row_height);
                                    }
                                    if ($last && $row_height > wppa_get_thumby($id)) {
                                        $row_height = $max_row_height;
                                    }
                                    $row_height_p = $row_height / $cont_width * 100;
                                    wppa_out('<tr class="wppa-masonry" >' . '<td style="border:none;padding:0;margin:0" >' . '<div' . ' id="wppa-mas-h-' . $tr_count . '-' . wppa('mocc') . '"' . ' style="height:' . $row_height . 'px;"' . ' class="wppa-masonry"' . ' data-height-perc="' . $row_height_p . '"' . ' >');
                                    wppa_out($row_content);
                                    wppa_out('</div></td></tr>');
                                    $row_content = '';
                                    $row_width = 0;
                                    $row_height = wppa_opt('wppa_thumbsize');
                                    $rw_count = 0;
                                    $tr_count += '1';
                                }
                            }
                        }
                        wppa_out('</tbody></table>');
                        // The footer
                        wppa_album_name('bottom');
                        // Optionally display album name
                        wppa_album_desc('bottom');
                        // Optionally display album description
                        wppa_thumb_area('close');
                        // Close Thumbarea sub-container
                    } elseif (wppa_opt('wppa_thumbtype') == 'default') {
                        // Do the thumbs As default
                        // The header
                        wppa_thumb_area('open');
                        // Open Thumbarea sub-container
                        wppa_popup();
                        // Prepare Popup box
                        wppa_album_name('top');
                        // Optionally display album name
                        wppa_album_desc('top');
                        // Optionally display album description
                        // Init
                        $relpage = wppa_switch('wppa_thumbs_first') ? $curpage : $curpage - $n_album_pages;
                        // Process the thumbnails
                        if ($thumbs) {
                            foreach ($thumbs as $tt) {
                                $counter_thumbs++;
                                if (wppa_onpage('thumbs', $counter_thumbs, $relpage)) {
                                    $didsome = true;
                                    wppa_thumb_default($tt['id']);
                                    // Show Thumb as default
                                }
                                // End if on page
                            }
                        }
                        // The footer
                        wppa_album_name('bottom');
                        // Optionally display album name
                        wppa_album_desc('bottom');
                        // Optionally display album description
                        wppa_thumb_area('close');
                        // Close Thumbarea sub-container
                    } else {
                        wppa_out('Unimplemented thumbnail type');
                    }
                }
            }
        }
        // If thumbs
        if ($didsome && wppa_is_pagination()) {
            $albums = false;
        }
        // Pag on and didsome: force a pagebreak by faking no albums
        if (!wppa_is_pagination()) {
            $n_thumb_pages = '0';
        }
        // Still on page one
        // Process the albums
        if (wppa_switch('wppa_thumbs_first')) {
            if ($albums) {
                $counter_albums = '0';
                wppa_album_list('open');
                // Open Albums sub-container
                foreach ($albums as $album) {
                    // Loop the albums
                    $counter_albums++;
                    if (wppa_onpage('albums', $counter_albums, $curpage - $n_thumb_pages)) {
                        wppa_album_cover($album['id']);
                        // Show the cover
                        $didsome = true;
                    }
                    // End if on page
                }
                wppa_album_list('close');
                // Close Albums sub-container
            }
            // If albums
        }
        // Make pagelinkbar if requested on bottom
        if (wppa_opt('pagelink_pos') == 'bottom' || wppa_opt('pagelink_pos') == 'both') {
            wppa_page_links($totpag, $curpage);
        }
        // Empty results?
        if (!$didsome && !$wanted_empty) {
            if (wppa('photos_only')) {
                wppa_out(wppa_errorbox(__a('No photos found matching your search criteria.', 'wppa_theme')));
            } elseif (wppa('albums_only')) {
                wppa_out(wppa_errorbox(__a('No albums found matching your search criteria.', 'wppa_theme')));
            } else {
                wppa_out(wppa_errorbox(__a('No albums or photos found matching your search criteria.', 'wppa_theme')));
            }
        }
    } elseif (wppa_page('slide') || wppa_page('single')) {
        // Page 'Slideshow' or 'Single' in browsemode requested
        $thumbs = wppa_get_thumbs();
        wppa_dbg_msg('From theme: #thumbs=' . ($thumbs ? count($thumbs) : '0'));
        if ($thumbs) {
            wppa_the_slideshow();
            // Producs all the html required for the slideshow
            wppa_run_slidecontainer('slideshow');
            // Fill in the photo array and display it.
        } else {
            wppa_out(wppa_errorbox(__a('No photos found matching your search criteria.', 'wppa_theme')));
        }
    }
    // wppa_page( 'slide' )
    // Close container
    wppa_container('close');
}
Exemplo n.º 3
0
function wppa_get_imagex($id, $key = 'photo')
{
    if (wppa_is_video($id)) {
        $result = wppa_get_videox($id);
    } elseif ($key == 'thumb') {
        $result = wppa_get_thumbx($id);
    } else {
        $result = wppa_get_photox($id);
    }
    return $result;
}
function wppa_album_photos_sequence($album)
{
    global $wpdb;
    if ($album) {
        $photoorder = wppa_get_photo_order($album, 'norandom');
        $is_descending = strpos($photoorder, 'DESC') !== false;
        $is_p_order = strpos($photoorder, 'p_order') !== false;
        $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s ' . $photoorder, $album), ARRAY_A);
        $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&bulk');
        $size = '180';
        if ($photos) {
            ?>
			<style>
				.sortable-placeholder {
					width: <?php 
            echo $size;
            ?>
px;
					height: <?php 
            echo $size;
            ?>
px;
					margin: 5px;
					border: 1px solid #cccccc;
					border-radius:3px;
					float: left;
				}
				.ui-state-default {
					position: relative;
					width: <?php 
            echo $size;
            ?>
px;
					height: <?php 
            echo $size;
            ?>
px;
					margin: 5px;
					border-radius:3px;
					float: left;
				}
				.wppa-publish {
					border: 1px solid;
					background-color: rgb( 255, 255, 224 );
					border-color: rgb( 230, 219, 85 );
				}
				.wppa-featured {
					border: 1px solid;
					background-color: rgb( 224, 255, 224 );
					border-color: rgb( 85, 238, 85 );
				}
				.wppa-pending {
					border: 1px solid;
					background-color: rgb( 255, 235, 232 );
					border-color: rgb( 204, 0, 0 );
				}
			</style>
			<script>
				jQuery( function() {
					jQuery( "#sortable" ).sortable( {
						cursor: "move",
						placeholder: "sortable-placeholder",
						stop: function( event, ui ) {
							var ids = jQuery( ".wppa-sort-item" );
							var seq = jQuery( ".wppa-sort-seqn" );
							var idx = 0;
							var descend = <?php 
            if ($is_descending) {
                echo 'true';
            } else {
                echo 'false';
            }
            ?>
;
							while ( idx < ids.length ) {
								var newvalue;
								if ( descend ) newvalue = ids.length - idx;
								else newvalue = idx + 1;
								var oldvalue = seq[idx].value;
								var photo = ids[idx].value;
								if ( newvalue != oldvalue ) {
									wppaDoSeqUpdate( photo, newvalue );
								}
								idx++;
							}
						}
					} );
				} );
				function wppaDoSeqUpdate( photo, seqno ) {
					var data = 'action=wppa&wppa-action=update-photo&photo-id='+photo+'&item=p_order&wppa-nonce='+document.getElementById( 'photo-nonce-'+photo ).value+'&value='+seqno;
					var xmlhttp = new XMLHttpRequest();

					xmlhttp.onreadystatechange = function() {
						if ( xmlhttp.readyState == 4 && xmlhttp.status != 404 ) {
							var ArrValues = xmlhttp.responseText.split( "||" );
							if ( ArrValues[0] != '' ) {
								alert( 'The server returned unexpected output:\n'+ArrValues[0] );
							}
							switch ( ArrValues[1] ) {
								case '0':	// No error
									jQuery( '#wppa-seqno-'+photo ).html( seqno );
									break;
								case '99':	// Photo is gone
									jQuery( '#wppa-seqno-'+photo ).html( '<span style="color"red" >deleted</span>' );
									break;
								default:	// Any error
									jQuery( '#wppa-seqno-'+photo ).html( '<span style="color"red" >Err:'+ArrValues[1]+'</span>' );
									break;
							}
						}
					}
					xmlhttp.open( 'POST',wppaAjaxUrl,true );
					xmlhttp.setRequestHeader( "Content-type","application/x-www-form-urlencoded" );
					xmlhttp.send( data );
					jQuery( "#wppa-sort-seqn-"+photo ).attr( 'value', seqno );	// set hidden value to new value to prevent duplicate action
					var spinnerhtml = '<img src="'+wppaImageDirectory+'wpspin.gif'+'" />';
					jQuery( '#wppa-seqno-'+photo ).html( spinnerhtml );
				}
			</script>
			<?php 
            if (!$is_p_order) {
                wppa_warning_message(__('Setting photo sequence order has only effect if the photo order method is set to <b>Order#</b>', 'wp-photo-album-plus'));
            }
            ?>
			<div class="widefat" style="border-color:#cccccc" >
				<div id="sortable">
					<?php 
            foreach ($photos as $photo) {
                if (wppa_is_video($photo['id'])) {
                    $imgs['0'] = wppa_get_videox($photo['id']);
                    $imgs['1'] = wppa_get_videoy($photo['id']);
                } else {
                    //							$imgs = getimagesize( wppa_get_thumb_path( $photo['id'] ) );
                    $imgs['0'] = wppa_get_thumbx($photo['id']);
                    $imgs['1'] = wppa_get_thumby($photo['id']);
                }
                if (!$imgs['0']) {
                    // missing thuimbnail, prevent division by zero
                    $imgs['0'] = 200;
                    $imgs['1'] = 150;
                }
                $mw = $size - '20';
                $mh = $mw * '3' / '4';
                if ($imgs[1] / $imgs[0] > $mh / $mw) {
                    // more portrait than 200x150, y is limit
                    $mt = '15';
                } else {
                    // x is limit
                    $mt = ($mh - $imgs[1] / $imgs[0] * $mw) / '2' + '15';
                }
                ?>
					<div id="photoitem-<?php 
                echo $photo['id'];
                ?>
" class="ui-state-default wppa-<?php 
                echo $photo['status'];
                ?>
" style="background-image:none; text-align:center; cursor:move;" >
					<?php 
                if (wppa_is_video($photo['id'])) {
                    ?>
					<?php 
                    $id = $photo['id'];
                    ?>
					<?php 
                    $imgstyle = 'max-width:' . $mw . 'px; max-height:' . $mh . 'px; margin-top:' . $mt . 'px;';
                    ?>
					<?php 
                    echo wppa_get_video_html(array('id' => $id, 'controls' => false, 'tagid' => 'pa-id-' . $id, 'preload' => 'metadata', 'class' => 'wppa-bulk-thumb', 'style' => $imgstyle, 'use_thumb' => true));
                    ?>
	<!--					<video preload="metadata" class="wppa-bulk-thumb" style="max-width:<?php 
                    echo $mw;
                    ?>
px; max-height:<?php 
                    echo $mh;
                    ?>
px; margin-top: <?php 
                    echo $mt;
                    ?>
px;" >
						 // echo //wppa_get_video_body( $photo['id'] ) ?>
						</video>
	-->
					<?php 
                } else {
                    ?>
						<img class="wppa-bulk-thumb" src="<?php 
                    echo wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']);
                    ?>
" style="max-width:<?php 
                    echo $mw;
                    ?>
px; max-height:<?php 
                    echo $mh;
                    ?>
px; margin-top: <?php 
                    echo $mt;
                    ?>
px;" />
					<?php 
                }
                ?>
						<div style="font-size:9px; position:absolute; bottom:24px; text-align:center; width:<?php 
                echo $size;
                ?>
px;" ><?php 
                echo wppa_get_photo_name($photo['id']);
                ?>
</div>
						<div style="text-align: center; width: <?php 
                echo $size;
                ?>
px; position:absolute; bottom:8px;" >
							<span style="margin-left:15px;float:left"><?php 
                echo __('Id: ', 'wp-photo-album-plus') . $photo['id'];
                ?>
</span>
							<?php 
                if (wppa_is_video($photo['id'])) {
                    _e('Video', 'wp-photo-album-plus');
                }
                ?>
							<?php 
                if (wppa_has_audio($photo['id'])) {
                    _e('Audio', 'wp-photo-album-plus');
                }
                ?>
							<span style="float:right; margin-right:15px;"><?php 
                echo __('Ord: ', 'wp-photo-album-plus') . '<span id="wppa-seqno-' . $photo['id'] . '" >' . $photo['p_order'];
                ?>
</span>
						</div>
						<input type="hidden" id="photo-nonce-<?php 
                echo $photo['id'];
                ?>
" value="<?php 
                echo wp_create_nonce('wppa_nonce_' . $photo['id']);
                ?>
" />
						<input type="hidden" class="wppa-sort-item" value="<?php 
                echo $photo['id'];
                ?>
" />
						<input type="hidden" class="wppa-sort-seqn" id="wppa-sort-seqn-<?php 
                echo $photo['id'];
                ?>
" value="<?php 
                echo $photo['p_order'];
                ?>
" />
					</div>
					<?php 
            }
            ?>
				</div>
				<div style="clear:both;"></div>
			</div>
			<?php 
        } else {
            echo '<h3>' . __('The album is empty.', 'wp-photo-album-plus') . '</h3>';
        }
    } else {
        wppa_dbg_msg('Missing required argument in wppa_album_photos() 3', 'red', 'force');
    }
}