Skip to content
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

Fix Aligner with caption on multiple image #467

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions _includes/aligner.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
{% assign column = 100.0 | divided_by: include.column %}
{% endif %}

<div class="row">
<figure>
{% for image in images %}
<div {% if column %} style="flex: {{ column }}%" {% else %} class="column" {% endif %} >
<img {% if images.size == 1 %}class="single"{% endif %}
src="{{ image | prepend: 'assets/img/' | relative_url }}"
alt="{{ image | prepend: '/' | split: '/' | last }}">
</div>
{% endfor %}
{% if include.caption %}
<figcaption class="caption-style">{{ include.caption }}</figcaption>
{% endif %}
</figure>
</div>

<figure class="row">
{% for image in images %}
<div class="column">
<img {% if images.size== 1 %}class="single" {% endif %}
src="{{ image | prepend: 'assets/img/' | relative_url }}"
alt="{{ image | prepend: '/' | split: '/' | last }}">
</div>
{% endfor %}
{% if include.caption %}
{% endif %}
<figcaption class="caption-style">{{ include.caption }}</figcaption>
</figure>


{% assign column = false %}
8 changes: 4 additions & 4 deletions _posts/2018-10-29-feature-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ It by default look into `assets/img/` so give the path from there, example:

{% highlight ruby %}
{% raw %}
{% include aligner.html images="pexels/book-glass.jpeg,triangle.png" %}
{% include aligner.html images="pexels/book-glass.jpeg,triangle.png" caption="A caption under the images" %}
{% endraw %}
{% endhighlight %}

{% include aligner.html images="pexels/book-glass.jpeg,feature-img/desk-messy.jpeg" %}
{% include aligner.html images="pexels/book-glass.jpeg,feature-img/desk-messy.jpeg" caption="A caption under the images" %}


Here you have two images side by side, but you can set more and set the amount per columns
Expand All @@ -50,9 +50,9 @@ However you can just use the Markdown way of doing it to get the image normal si

{% highlight ruby %}
{% raw %}
# Markdown way (bigger)
# Markdown way
![Travel]({{ "/assets/img/pexels/computer.jpeg" | relative_url}})
# Aligner with only One (50% of width)
# Aligner with only one image
{% include aligner.html images="pexels/computer.jpeg" %}
{% endraw %}
{% endhighlight %}
Expand Down
10 changes: 0 additions & 10 deletions _sass/base/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,4 @@ details {
padding-top: 2em;
max-width: 100%;
}
}

.caption-style {
font-style: italic;
font-size: 0.8em;
text-align: center;
color: var(--meta);
font-weight: 200;
padding-bottom: 5px;
padding-top: 5px;
}
33 changes: 33 additions & 0 deletions _sass/includes/_aligner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* --- Aligner --- */

.row {
display: flex;
flex-wrap: wrap;
flex-direction: row;
padding: 0.9% 0 1.5% 0;
}

.caption-style {
order: 1;
flex: 1 1 100%;
display: block;
font-style: italic;
font-size: 0.8em;
text-align: center;
color: var(--meta);
font-weight: 200;
padding-bottom: 5px;
padding-top: 5px;
}

.column {
flex: 1 0;

img {
min-width: 250px;
}
.single {
width: 100%;
display: block;
}
}
26 changes: 0 additions & 26 deletions _sass/layouts/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,3 @@ h1.title {
margin-top: 5px;
text-shadow: 1px 1px 2px var(--text-shadow);
}

//Shared css in _post.scss


/* --- Aligner --- */
/* within page/posts */

.row {
display: flex;
flex-wrap: wrap;
padding: 0.9% 0 1.5% 0;
}

.column {
flex: 50%;

img {
width: 100%;
min-width: 250px;
}

.single {
width: 50%;
display: block;
}
}
1 change: 1 addition & 0 deletions _sass/type-on-strap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@import 'includes/blog_nav';
@import 'includes/gallery';
@import 'includes/portfolio';
@import 'includes/aligner';
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using custom scss for the theme, don't forget to add to get the change. Otherwise the aligner look will be broken.


/* Posts */
// Linked with the html in the _layouts folder
Expand Down
Loading