Improvements to grid view mode.

This commit is contained in:
mateuswetah 2022-09-05 11:02:02 -03:00
parent bd0f07b769
commit 5ca1fa4008
1 changed files with 21 additions and 8 deletions

View File

@ -1,17 +1,30 @@
<?php
$is_slideshow_available = false;
if (function_exists('tainacan_is_view_mode_enabled'))
$is_slideshow_available = tainacan_is_view_mode_enabled('slideshow');
?>
$is_slideshow_available = false;
if (function_exists('tainacan_is_view_mode_enabled'))
$is_slideshow_available = tainacan_is_view_mode_enabled('slideshow');
function get_item_link_for_navigation($item_url, $index) {
if ( $_GET && isset($_GET['paged']) && isset($_GET['perpage']) ) {
$query = '';
$perpage = (int)$_GET['perpage'];
$paged = (int)$_GET['paged'];
$index = (int)$index;
$query .= '&pos=' . ( ($paged - 1) * $perpage + $index );
$query .= '&source_list=' . (is_tax() ? 'term' : ((!isset($collection_id) || empty($collection_id)) ? 'repository': 'collection') );
return $item_url . '?' . $_SERVER['QUERY_STRING'] . $query;
}
return $item_url;
}
?>
<?php if ( have_posts() ) : ?>
<div class="tainacan-grid-container">
<?php $item_index = 0; while ( have_posts() ) : the_post(); ?>
<div class="tainacan-grid-item">
<div class="metadata-title">
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<p><a href="<?php echo get_item_link_for_navigation(get_permalink(), $item_index); ?>"><?php the_title(); ?></a></p>
<?php if ( $is_slideshow_available ) : ?>
<a href="<?php echo esc_url('?' . $_SERVER['QUERY_STRING'] . '&slideshow-from=' . $item_index ); ?>" class="icon slideshow-icon">
<i class="tainacan-icon tainacan-icon-viewgallery tainacan-icon-1-125em"></i>
@ -20,7 +33,7 @@
</div>
<?php if ( has_post_thumbnail() ) : ?>
<a
href="<?php the_permalink(); ?>"
href="<?php echo get_item_link_for_navigation(get_permalink(), $item_index); ?>"
style="background-image: url(<?php the_post_thumbnail_url( 'tainacan-medium' ) ?>)"
class="grid-item-thumbnail">
<?php the_post_thumbnail( 'tainacan-medium' ); ?>
@ -28,7 +41,7 @@
</a>
<?php else : ?>
<a
href="<?php the_permalink(); ?>"
href="<?php echo get_item_link_for_navigation(get_permalink(), $item_index); ?>"
style="background-image: url(<?php echo esc_url( get_template_directory_uri() ) . '/assets/images/thumbnail_placeholder.png'?>)"
class="grid-item-thumbnail">
<?php echo '<img alt="', esc_attr_e('Thumbnail placeholder', 'tainacan-interface'), '" src="', esc_url(get_template_directory_uri()), '/assets/images/thumbnail_placeholder.png">'?>