-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add carousel option to the posts #32
base: main
Are you sure you want to change the base?
Changes from 9 commits
c4ad535
acb29d4
4333e8a
3da8b4f
fabf93a
c1e6f71
c89b1fd
177f161
3a07d8f
39b7b9c
c18eed8
3bc5853
9f2cc00
58424c7
4b4ec52
6d1b6bf
073aac5
4f0ffba
2ad4640
d648de6
aaf64ec
f83b573
036bed5
dc1856e
3fd5bfb
6027e2b
ebd7053
4e7bee4
816a197
c2fd84c
71a3bca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.thumbnails { | ||
margin: 20px 0; | ||
text-align: center; | ||
} | ||
.thumbnails li { | ||
display: inline-block; | ||
cursor: pointer; | ||
border: 5px solid #fff; | ||
} | ||
.thumbnails .tns-nav-active { | ||
background: none; | ||
border-color: #000; | ||
} | ||
.thumbnails li { width: 50px; } | ||
.thumbnails img { vertical-align: bottom; height: auto; max-height: 50px; } | ||
.controls { text-align: center; } | ||
.controls li { | ||
display: block; | ||
position: relative; | ||
height: 60px; | ||
width: 32px; | ||
line-height: 60px; | ||
/* margin-top: calc(-60% - 50px); */ | ||
margin-top: -70px; | ||
padding: 0px 0px; | ||
cursor: pointer; | ||
transition: background 0.3s; | ||
} | ||
.controls li img { display: inline-block; vertical-align: middle; } | ||
.controls .prev { left: 0; } | ||
.controls .next { float: right; | ||
margin-top: -63px;} | ||
.controls li:hover { background: #f2f2f2; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
+++ | ||
title = "Carousel with image description" | ||
description = "Post with carousel which has image description, but can also omit it " | ||
summary = "" | ||
toc = true | ||
authors = ["Example Author"] | ||
tags = ["image"] | ||
categories = ["themes"] | ||
series = ["Themes Guide"] | ||
date = "2020-05-26" | ||
lastmod = "2020-05-26" | ||
draft = false | ||
|
||
carousel = [ | ||
{ image = "../carousel1.png", description = "Caption of the first image." }, | ||
{ image = "../carousel2.png", description = "Caption of the second image." }, | ||
{ image = "../carousel3.png", description = "The next image does not have a caption." }, | ||
{ image = "../carousel4.png" } | ||
] | ||
+++ | ||
|
||
This post includes a carousel on the end. It is displayed like a gallery and you can | ||
move around the images so that they do not take too much space. Style is at the moment | ||
not configurable, but configuration of the carousel style could be done in the future. | ||
|
||
<!--more--> | ||
|
||
## Example subtitle for carousel | ||
|
||
Aenean vehicula non elit id varius. Mauris condimentum lacinia mollis. Nullam quis cursus metus, eget mattis erat. Aliquam nec ante lacus. In tellus augue, iaculis vitae sollicitudin quis, tempor nec urna. Aenean ut fermentum erat, vel gravida ligula. Etiam sed ex aliquet, egestas nibh eu, iaculis mi. Nunc sit amet fermentum ex. Sed convallis ac arcu tristique rhoncus. Suspendisse potenti. | ||
|
||
Proin justo purus, porttitor et semper ut, commodo et nibh. Nam malesuada id arcu in tempus. Ut ornare vestibulum ultrices. Nullam tempor lectus quis ornare viverra. Vestibulum fringilla turpis ac leo fermentum, et dictum nisi consectetur. Integer ullamcorper fringilla mi, non volutpat sapien ultrices vel. Phasellus at blandit neque, pulvinar rutrum ante. | ||
|
||
Etiam auctor, elit vel pretium consequat, orci magna aliquet dolor, quis varius felis purus ut elit. Sed ultrices feugiat blandit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Ut accumsan pulvinar purus et ornare. Vestibulum et tortor eget lacus hendrerit porttitor. Cras dapibus ac est posuere mattis. Pellentesque eu ligula ultricies, interdum nulla vel, sollicitudin ligula. Suspendisse sit amet massa sed dui placerat pharetra. Vestibulum massa sem, congue in vehicula vitae, aliquam eu mi. Suspendisse eget laoreet velit. Cras felis enim, molestie in enim nec, mollis venenatis lectus. Donec tincidunt, mi vel interdum varius, urna metus aliquet velit, ut venenatis nulla orci nec lectus. Nam id tortor imperdiet, tempor massa eget, congue nisl. Suspendisse venenatis facilisis orci, non scelerisque risus volutpat sit amet. | ||
|
||
## Example subtitle2 for the carousel | ||
|
||
After this section, you are suppose to see the carousel. | ||
|
||
Aliquam posuere diam non ligula tristique congue. Donec dignissim eu justo sed dictum. Praesent at massa erat. Praesent mollis viverra velit. Aliquam maximus pharetra massa a efficitur. Sed tempus egestas purus sit amet tempor. Donec porttitor varius nisi, eu venenatis risus gravida id. Pellentesque blandit nunc non urna consectetur commodo. Sed at feugiat felis, sit amet malesuada nunc. Curabitur in tempor nisl. Pellentesque accumsan est orci, in commodo felis accumsan facilisis. Nulla maximus suscipit posuere. Nulla et consequat mauris, fermentum ultricies tellus. | ||
|
||
Maecenas consectetur ac libero vitae congue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec tortor eu lectus placerat varius. Mauris a nisi consectetur, ornare dolor ut, rutrum ligula. Sed enim nisl, fermentum a dictum vel, vestibulum ut odio. Suspendisse laoreet quis urna eu vestibulum. Maecenas commodo augue ex, eu egestas nulla aliquet ut. Cras aliquam dui ipsum, nec sodales erat convallis sit amet. Donec porttitor posuere hendrerit. Sed imperdiet at purus eget tempus. In ac est urna. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
+++ | ||
title = "Carousel with image array" | ||
description = "Post with carousel which does not have description per image" | ||
summary = "" | ||
toc = true | ||
authors = ["Example Author"] | ||
tags = ["image"] | ||
categories = ["themes"] | ||
series = ["Themes Guide"] | ||
date = "2020-05-26" | ||
lastmod = "2020-05-26" | ||
draft = false | ||
|
||
carousel = ["../carousel1.png", "../carousel2.png", "../carousel3.png", "../carousel4.png"] | ||
+++ | ||
|
||
This post includes a carousel without descriptions on the end. It is displayed like a gallery and you can | ||
move around the images so that they do not take too much space. Style is at the moment | ||
not configurable, but configuration of the carousel style could be done in the future. | ||
|
||
<!--more--> | ||
|
||
## Example subtitle for carousel | ||
|
||
Aenean vehicula non elit id varius. Mauris condimentum lacinia mollis. Nullam quis cursus metus, eget mattis erat. Aliquam nec ante lacus. In tellus augue, iaculis vitae sollicitudin quis, tempor nec urna. Aenean ut fermentum erat, vel gravida ligula. Etiam sed ex aliquet, egestas nibh eu, iaculis mi. Nunc sit amet fermentum ex. Sed convallis ac arcu tristique rhoncus. Suspendisse potenti. | ||
|
||
Proin justo purus, porttitor et semper ut, commodo et nibh. Nam malesuada id arcu in tempus. Ut ornare vestibulum ultrices. Nullam tempor lectus quis ornare viverra. Vestibulum fringilla turpis ac leo fermentum, et dictum nisi consectetur. Integer ullamcorper fringilla mi, non volutpat sapien ultrices vel. Phasellus at blandit neque, pulvinar rutrum ante. | ||
|
||
Etiam auctor, elit vel pretium consequat, orci magna aliquet dolor, quis varius felis purus ut elit. Sed ultrices feugiat blandit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Ut accumsan pulvinar purus et ornare. Vestibulum et tortor eget lacus hendrerit porttitor. Cras dapibus ac est posuere mattis. Pellentesque eu ligula ultricies, interdum nulla vel, sollicitudin ligula. Suspendisse sit amet massa sed dui placerat pharetra. Vestibulum massa sem, congue in vehicula vitae, aliquam eu mi. Suspendisse eget laoreet velit. Cras felis enim, molestie in enim nec, mollis venenatis lectus. Donec tincidunt, mi vel interdum varius, urna metus aliquet velit, ut venenatis nulla orci nec lectus. Nam id tortor imperdiet, tempor massa eget, congue nisl. Suspendisse venenatis facilisis orci, non scelerisque risus volutpat sit amet. | ||
|
||
## Example subtitle2 for the carousel | ||
|
||
After this section, you are suppose to see the carousel. | ||
|
||
Aliquam posuere diam non ligula tristique congue. Donec dignissim eu justo sed dictum. Praesent at massa erat. Praesent mollis viverra velit. Aliquam maximus pharetra massa a efficitur. Sed tempus egestas purus sit amet tempor. Donec porttitor varius nisi, eu venenatis risus gravida id. Pellentesque blandit nunc non urna consectetur commodo. Sed at feugiat felis, sit amet malesuada nunc. Curabitur in tempor nisl. Pellentesque accumsan est orci, in commodo felis accumsan facilisis. Nulla maximus suscipit posuere. Nulla et consequat mauris, fermentum ultricies tellus. | ||
|
||
Maecenas consectetur ac libero vitae congue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec tortor eu lectus placerat varius. Mauris a nisi consectetur, ornare dolor ut, rutrum ligula. Sed enim nisl, fermentum a dictum vel, vestibulum ut odio. Suspendisse laoreet quis urna eu vestibulum. Maecenas commodo augue ex, eu egestas nulla aliquet ut. Cras aliquam dui ipsum, nec sodales erat convallis sit amet. Donec porttitor posuere hendrerit. Sed imperdiet at purus eget tempus. In ac est urna. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<section> | ||
<div id="tinyslider-carousel"> | ||
{{ range $.Params.carousel }} | ||
<div class="item"> | ||
<div> | ||
{{ if reflect.IsMap . }} | ||
{{ $image := partial "utils/get-image" (dict "context" $ "url" .image "keyword" .image) }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added this get-image function calls (3a07d8f), yet the URL it produces is wrong as images are in public/posts yet this function resolves it to root . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we discussed before, there is a mistake in organizing images in content folder. You can create a folder named This is called Leaf Bundles in Hugo. And if you have done that, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done this in 39b7b9c . |
||
<img class="img-responsive" src="{{ $image }}" alt="{{ .description }}" /> | ||
</div> | ||
{{ if .description }} | ||
<p>{{ .description }}</p> | ||
{{ end }} | ||
{{ else }} | ||
{{ $image := partial "utils/get-image" (dict "context" $ "url" . "keyword" .) }} | ||
<img class="img-responsive" src="{{ $image }}" /> | ||
</div> | ||
{{ end }} | ||
</div> | ||
{{ end }} | ||
</div> | ||
<div class="tinyslider-controls"> | ||
<ul class="thumbnails" id="customize-thumbnails"> | ||
{{ range $.Params.carousel }} | ||
<li class="item"> | ||
{{ if reflect.IsMap . }} | ||
{{ $image := partial "utils/get-image" (dict "context" $ "url" .image "keyword" .image) }} | ||
<img class="img-responsive" src="{{ $image }}" alt="{{ .description }}" width="50px" /> | ||
{{ else }} | ||
{{ $image := partial "utils/get-image" (dict "context" $ "url" . "keyword" .) }} | ||
<img class="img-responsive" src="{{ $image }}" width="50px" /> | ||
{{ end }} | ||
</li> | ||
{{ end }} | ||
</ul> | ||
<ul class="controls" id="customize-controls"> | ||
<li class="prev"><i class="fas fa-angle-left"></i></li> | ||
<li class="next"><i class="fas fa-angle-right"></i></li> | ||
</ul> | ||
</div> | ||
<script src="{{ printf .Site.Data.assets.tinyslider.js.url .Site.Data.assets.tinyslider.version }}"></script> | ||
<script> const slider = tns({ | ||
container: '#tinyslider-carousel', | ||
items: 1, | ||
autoplay: false, | ||
center: true, | ||
nav: true, | ||
navContainer: "#customize-thumbnails", | ||
controlsContainer: "#customize-controls", | ||
navAsThumbnails: true, | ||
autoHeight: true, | ||
}); | ||
</script> | ||
|
||
</section> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is exactly what I want. In order to unify the format, I think the
image
can be renamed tourl
Besides, how about combining
featuredImage
andcarousel
into one attribute? When the newfeaturedImage
is a string or an array which only contains one item, it will be the oldfeaturedImage
. And if this attribute has more than one item, carousel will be used. What do you think of this idea?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of too much automatization as I see a use case where featured image is not part of the carousel set. For example in featured image you make something totally related to title, to attract a reader, but then in carousel you just have images of details.
Based on below proposal of adding a video, I would leave
image
as that would enable us to usevideo
and swap the text inside div from<img>
to<video>