Giter Club home page Giter Club logo

picoresponsiveimages's Introduction

Pico Responsive Images

This is a plugin for Pico CMS which provides a Markdown-like syntax to include lazy loaded images in your pages, powered by aFarkas/lazysizes. You can also include multiple sizes of source image per image element -- the user's browser then chooses the best one to download and display based on the conditions.

It's a convenient way to lazy load your images, and make use of the HTML5 srcset attribute.

Install

  1. Download the latest release of this plugin and decompress the folder to your Pico plugins directory.
  2. This plugin is effectively a nice abstraction within Markdown for aFarkas/lazysizes, so make sure to include lazysizes in your theme file. The easiest way to do it is by adding a script tag from cdnjs to your theme file, just before the closing <body> tag.
  3. Images won't lazy load when JavaScript is disabled. Instead, they'll fallback onto a standard image using <noscript>. To hide the non-functioning lazy loading images when the user has JavaScript disabled, add the following code to your theme's <head>.
<noscript>
   <style>
       // Hide images which should lazy load
       .lazyload {
           display: none;
       }
   </style>
</noscript>

If you're looking for ways of adding a loading animation to your images, check the lazysizes repo.

Usage

All images added with this plugin's syntax have 100% width.

Lazy loading images

Include an image using the standard Markdown syntax, but swap ! for ?.

  • ?[A cat on a mat](/assets/cat.png)

Lazy loading responsive images

Include an image using the standard Markdown syntax, but swap ! for ?, and provide a comma-separated list of paths and sizes or resolutions. The first path provided is the "default" in case the browser doesn't support the src attribute, or if JavaScript is disabled.

For example:

  • ?[A cat on a mat](/assets/cat-500w.png 500w, /assets/cat-1000w.png 1000w)
  • ?[A cat on a mat](/assets/cat-1x.png 1x, /assets/cat-2x.png 2x)

picoresponsiveimages's People

Contributors

wlabarron avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.