Generate nice JPEG and PNG files from any SVG files in your images/
folder.
Also, generate gzipped SVGZ files.
Attention: This requires Inkscape.
Add this line to your Gemfile
:
gem 'middleman-svg-fallback'
Activate the plugin in your config.rb:
activate :svg_fallback
You may provide the path to your inkscape binary, if it's not in the PATH
.
E.g. on macOS, you may use the following configuration:
activate :svg_fallback, inkscape_bin: '/Applications/Inkscape.app/Contents/Resources/bin/inkscape'
Furthermore, you may configure command line arguments, that should be passed on to inkscape:
activate :svg_fallback, inkscape_options: '--export-dpi=100 --export-background-opacity=0'
If configured properly, middleman-svg-fallback will generate fallback images
(PNGs and JPGs) for all SVGs within your images_dir
as you would expect. You
can use them with a modernizr based CSS rule, like this
for example:
.illustration {
background: url('illustration.svg') 0 0 no-repeat;
}
.no-svg .illustration {
background: url('illustration.png') 0 0 no-repeat;
}
The generated JPEG files are intended for use with OpenGraph.
Facebook doesn't like PNGs in og:image
properties, so the JPG versions will
come in handy.
This software is licensed under the MIT License. View the license.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
To run the tests follow these steps:
- Clone the repository
- Run
bundle install
to install all development dependencies - Use
rake
to execute the test suite a. If inkscape is not in your PATH, you may provide the optionalINKSCAPE_PATH
environment variable, e.g.INKSCAPE_PATH=/path/to/inkscape rake