From 41dc3d9877b4c4267a96b8f60241f2059657c443 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Tue, 31 Jul 2018 19:25:54 -0300 Subject: [PATCH] Fix attachments with carousel --- build.sh | 3 ++- src/assets/js/js.js | 39 ++++++++++++++++++++++++++++++++--- src/assets/scss/_post.scss | 33 +++++++++++++++++++++++++++++ src/tainacan/single-items.php | 24 ++++++++++----------- 4 files changed, 83 insertions(+), 16 deletions(-) diff --git a/build.sh b/build.sh index f75cfa5..cb6993b 100755 --- a/build.sh +++ b/build.sh @@ -25,7 +25,8 @@ rm -rf $destination/assets/vendor/bootstrap/scss mkdir $destination/assets/vendor/slick/css cp $destination/assets/vendor/slick/scss/slick.min.css $destination/assets/vendor/slick/css/slick.min.css cp $destination/assets/vendor/slick/scss/slick-theme.min.css $destination/assets/vendor/slick/css/slick-theme.min.css -cp $destination/assets/vendor/slick/ajax-loader.gif $destination/assets/vendor/slick/css/ajax-loader.gif +mv $destination/assets/vendor/slick/ajax-loader.gif $destination/assets/vendor/slick/css/ajax-loader.gif +mv $destination/assets/vendor/slick/fonts/ $destination/assets/vendor/slick/css/fonts/ rm -rf $destination/assets/vendor/slick/scss echo "Compilation Finish!!" diff --git a/src/assets/js/js.js b/src/assets/js/js.js index 8de32c1..10a3606 100644 --- a/src/assets/js/js.js +++ b/src/assets/js/js.js @@ -95,9 +95,42 @@ jQuery(document).ready(function( $ ) { }); $('.single-item-collection--attachments').slick({ - dots: true, + prevArrow: '', + nextArrow: '', + slidesToShow: 6, + slidesToScroll: 1, + autoplay: true, + autoplaySpeed: 2000, + responsive: [ + { + breakpoint: 1024, + settings: { + slidesToShow: 5, + slidesToScroll: 1 + } + }, + { + breakpoint: 768, + settings: { + slidesToShow: 4, + slidesToScroll: 1 + } + }, + { + breakpoint: 576, + settings: { + slidesToShow: 2, + slidesToScroll: 1 + } + } + // You can unslick at a given breakpoint now by adding: + // settings: "unslick" + // instead of a settings object + ] + }); + + /* $('.single-item-collection--attachments').slick({ speed: 300, - variableWidth: true, prevArrow: '', nextArrow: '', responsive: [ @@ -137,5 +170,5 @@ jQuery(document).ready(function( $ ) { // settings: "unslick" // instead of a settings object ] - }); + }); */ }); diff --git a/src/assets/scss/_post.scss b/src/assets/scss/_post.scss index 398e8e3..d0c85f4 100644 --- a/src/assets/scss/_post.scss +++ b/src/assets/scss/_post.scss @@ -126,6 +126,39 @@ } } } + .single-item-collection--attachments { + .single-item-collection--attachments-img { + margin: 10px; + } + .single-item-collection--attachments-prev { + left: -50px; + } + .single-item-collection--attachments-next { + right: 0px; + @media only screen and (min-width: 1500px) { + right: -25px; + } + } + .single-item-collection--attachments-prev, .single-item-collection--attachments-next { + position: absolute; + display: block; + height: 33px; + width: 18px; + line-height: 0px; + font-size: 60px; + color: #298596; + cursor: pointer; + background: transparent; + top: 50%; + -webkit-transform: translate(0, -50%); + -ms-transform: translate(0, -50%); + transform: translate(0, -50%); + padding: 0; + border: none; + outline: none; + } + + } .single-item-collection--information{ .card{ .item-card--thumbnail{ diff --git a/src/tainacan/single-items.php b/src/tainacan/single-items.php index 7daf618..9d142d4 100644 --- a/src/tainacan/single-items.php +++ b/src/tainacan/single-items.php @@ -34,6 +34,15 @@ + get_the_ID(), + 'post_type' => 'attachment', + 'post_per_page' => -1, + 'exclude' => get_post_thumbnail_id( get_the_ID() ) + )); + if ( !empty($images) ) { + ?>
@@ -44,24 +53,15 @@
get_the_ID(), - 'post_type' => 'attachment', - 'post_per_page' => -1, - 'exclude' => get_post_thumbnail_id( get_the_ID() ) - )); - if ( empty($images) ) { - echo 'no attachments here'; - } else { - foreach ( $images as $attachment ) { - echo '
' . wp_get_attachment_image( $attachment->ID, 'medium' ) . '
'; - } + foreach ( $images as $attachment ) { + echo '
' . wp_get_attachment_image( $attachment->ID, 'tainacan-theme-list-post' ) . '
'; } ?>
+