Allow floating images to start/end of a paragraph

This commit is contained in:
daudix
2024-06-27 22:55:35 +03:00
parent c4e48dedf7
commit fa8b441f7b
4 changed files with 77 additions and 6 deletions

View File

@ -178,7 +178,9 @@ Available variables are:
- `url`: URL to an image. - `url`: URL to an image.
- `url_min`: URL to compressed version of an image, original can be opened by clicking on the image. - `url_min`: URL to compressed version of an image, original can be opened by clicking on the image.
- `alt`: Alt text, same as if the text were inside square brackets in Markdown. - `alt`: Alt text, same as if the text were inside square brackets in Markdown.
- `full`: Forces image/video to be full-width. - `full`: Forces image to be full-width.
- `start`: Float image to the start of paragraph and scale it down.
- `end`: Float image to the end of paragraph and scale it down.
- `pixels`: Uses nearest neighbor algorithm for scaling, useful for keeping pixel-art sharp. - `pixels`: Uses nearest neighbor algorithm for scaling, useful for keeping pixel-art sharp.
- `transparent`: Removes rounded corners and shadow, useful for transparent images. - `transparent`: Removes rounded corners and shadow, useful for transparent images.
- `no_hover`: Removes zoom on hover. - `no_hover`: Removes zoom on hover.
@ -197,14 +199,21 @@ Variables should be comma-separated and be inside the brackets.
Alternatively, you can append the following URL anchors. It can be more handy in some cases, e.g such images will render normally in any Markdown editor, opposed to the Zola shortcodes. Alternatively, you can append the following URL anchors. It can be more handy in some cases, e.g such images will render normally in any Markdown editor, opposed to the Zola shortcodes.
- `#full`: Forces image/video to be full-width. - `#full`: Forces image to be full-width.
- `#start`: Float image to the start of paragraph and scale it down.
- `#end`: Float image to the end of paragraph and scale it down.
- `#pixels`: Uses nearest neighbor algorithm for scaling, useful for keeping pixel-art sharp. - `#pixels`: Uses nearest neighbor algorithm for scaling, useful for keeping pixel-art sharp.
- `#transparent`: Removes rounded corners and shadow, useful for transparent images. - `#transparent`: Removes rounded corners and shadow, useful for transparent images.
- `#no-hover`: Removes zoom on hover. - `#no-hover`: Removes zoom on hover.
\
![Toolbx header image](https://containertoolbx.org/assets/toolbx.gif#full#pixels#transparent#no-hover) ![Toolbx header image](https://containertoolbx.org/assets/toolbx.gif#full#pixels#transparent#no-hover)
<figcaption>Full-width image with an alt text, pixel-art rendering, no shadow and rounded corners, and no zoom on hover</figcaption> <figcaption>Full-width image with an alt text, pixel-art rendering, no shadow and rounded corners, and no zoom on hover</figcaption>
\
![1966 Ford Mustang coupe white](https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/1966_Ford_Mustang_coupe_white_003.jpg/320px-1966_Ford_Mustang_coupe_white_003.jpg#start)
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim aeque doleamus animo, cum corpore dolemus, fieri tamen permagna accessio potest, si aliquod aeternum et infinitum impendere malum nobis opinemur.
#### Video #### Video
Same as images, but with a few differences: `no_hover` and `url_min` are not available. Same as images, but with a few differences: `no_hover` and `url_min` are not available.

View File

@ -11,6 +11,45 @@ video {
width: 100%; width: 100%;
} }
&.start,
&.end,
&[src*="#start"],
&[src*="#end"] {
margin: 0;
width: 30%;
@media only screen and (max-width: 720px) {
float: none;
margin-inline-start: 0;
margin-inline-end: 0;
width: 100%;
}
}
&.start,
&[src*="#start"] {
float: left;
transform-origin: left;
margin-inline-end: 1rem;
:root[dir="rtl"] & {
float: right;
transform-origin: right;
}
}
&.end,
&[src*="#end"] {
float: right;
transform-origin: right;
margin-inline-start: 1rem;
:root[dir="rtl"] & {
float: left;
transform-origin: left;
}
}
&.pixels, &.pixels,
&[src*="#pixels"] { &[src*="#pixels"] {
image-rendering: pixelated; image-rendering: pixelated;
@ -35,6 +74,23 @@ img {
border-radius: 0; border-radius: 0;
} }
&.start,
&.end,
&[src*="#start"],
&[src*="#end"] {
&:hover {
transform: scale(1.6);
}
@media only screen and (max-width: 720px) {
transform-origin: unset;
&:hover {
transform: scale(1.1);
}
}
}
&.transparent, &.transparent,
&[src*="#transparent"] { &[src*="#transparent"] {
&:hover { &:hover {

View File

@ -2,6 +2,8 @@
<a href="{{ url }}"> <a href="{{ url }}">
<img class=" <img class="
{% if full %}full{% endif %} {% if full %}full{% endif %}
{% if start %}start{% endif %}
{% if end %}end{% endif %}
{% if pixels %}pixels{% endif %} {% if pixels %}pixels{% endif %}
{% if transparent %}transparent{% endif %} {% if transparent %}transparent{% endif %}
{% if no_hover %}no-hover{% endif %} {% if no_hover %}no-hover{% endif %}
@ -12,6 +14,8 @@
{%- else -%} {%- else -%}
<img class=" <img class="
{% if full %}full{% endif %} {% if full %}full{% endif %}
{% if start %}start{% endif %}
{% if end %}end{% endif %}
{% if pixels %}pixels{% endif %} {% if pixels %}pixels{% endif %}
{% if transparent %}transparent{% endif %} {% if transparent %}transparent{% endif %}
{% if no_hover %}no-hover{% endif %} {% if no_hover %}no-hover{% endif %}

View File

@ -1,5 +1,7 @@
<video class=" <video class="
{% if full %}full{% endif %} {% if full %}full{% endif %}
{% if start %}start{% endif %}
{% if end %}end{% endif %}
{% if pixels %}pixels{% endif %} {% if pixels %}pixels{% endif %}
{% if transparent %}transparent{% endif %} {% if transparent %}transparent{% endif %}
" "