aboutsummaryrefslogtreecommitdiff
path: root/templates/shortcodes/imagehover.html
blob: 99dd4e4676c05953d39668eca6aafb2a0b2dfa8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{%- set_global bg = " " %}
{%- set_global bgname = " " %}
{%- for source in sources %}
  {%- set sourcename = source | split(pat=".") | first %}
  {%- if loop.first %}
    {%- set_global bg = source %}
    {%- set_global bgname = source | split(pat=".") | first %}
  {%- else %}

    <div id="{{ sourcename }}">## {{ sourcename }} </div>
    <div id="{{ sourcename }}image" alt="{{ sourcename }}"> </div>

  {%- endif %}
{%- endfor %}

{%- if w and h and p %}
  {%- set padding = h / w * p %}
{%- elif w and h %}
  {%- set padding = h / w * 50 %}
{%- else %}
  {%- set padding = 50 %}
{%- endif %}

<style>
  {%- for source in sources %}
    {%- set sourcename = source | split(pat=".") | first %}
    {%- if not loop.first %}
      #{{ sourcename | safe }}image {
        background-image: url('{{ get_url(path="/", trailing_slash=false) }}{{ page.path | safe }}{{ bg | safe }}');
        background-size: contain;
        background-repeat: no-repeat;
        width: {{ p | default(value=50) }}%;
        height: 0;
        padding-top: {{ padding }}%;
      }
      #{{ sourcename | safe }}image:hover {
        background-image: url('{{ get_url(path="/", trailing_slash=false) }}{{ page.path | safe }}{{ source | safe }}');
      }
    {%- endif %}
  {%- endfor %}
</style>