Skip to content

Conversation

@davidpede
Copy link

@davidpede davidpede commented Apr 12, 2018

Very helpful when using CSS solutions like: https://css-tricks.com/aspect-ratio-boxes/ to size dynamic width image containers and (or) lazy loading images. Example:

<html>
  <head>
    <style>
      .lazy-container {
        background-color: #C5C7C8;
        display: block;
        position: relative;
        height: 0;
        padding-top: 55.3%; //default
      }
      .lazy-container img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
    </style>
  </head>
  <body>
    [[pthumb? &input=`[[*image]]` &options=`w=200` &toPlaceholder=`thumb`]]
    <div class="column" style="width: 20%;"> //can be any width
      <a href="#" class="lazy-container" style="padding-top: [[+thumb.ratio]]%;">
        <img class="lazy" data-src="[[+thumb]]"> //remove 'data-' to view image
      </a>
    </div>
  </body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant