GithubHelp home page GithubHelp logo

nidi3 / jekyll-image_optimizer Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 0.0 12 KB

A jekyll plugin to optimize images for the web

License: Apache License 2.0

Ruby 100.00%
jekyll-plugin ruby optimize-images

jekyll-image_optimizer's Introduction

jekyll-image_optimizer

A jekyll plugin to optimize images for the web. It reads all the images in a source directory and saves optimized versions of them to a destination directory and creates a symbolic link to the destination directory.

Install it with gem install jekyll-image_optimizer.

Add this to your plugins/ext.rb file: require 'jekyll/image_optimizer'.

The following options for _config.yml are available:

Option Description Default value
raw_images the directory containing the unoptimized images img/raw
opt_images the directory containing the optimized images img/opt
images_link the name of the symbolic link pointing to opt_images images
image_geometry the size all images should be, is an ImageMagick geometry string and may be an array 800x800>
image_hash if the optimized image files should be appended with a hash to enable unlimited caching true
image_layout the file containing the template for the image tag (inside _layouts folder) image.html

The plugin defines two liquid tags: srcset and image. To include an image with multiple resolutions (using scrset) into a post, do the following:

In _layouts/image.html define the template of an image. For example:

<img srcset="{% srcset {{image.index}} %}" alt="{{image.alt}}"/>

In the front matter of the post, add

image:
    -   url: my_image.jpg
        alt: My Alt
        layout: my-image.html

and reference the image using {% image 0 %} where 0 is the index of the image. The optional layout parameter overwrites the image_layout parameter in _config.yml.

jekyll-image_optimizer's People

Contributors

nidi3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

jekyll-image_optimizer's Issues

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.