NoVector
NoVector is a Rails plugin automatically generates fallback bitmaps for vector images (e.g. SVG) when a client does not support them. It automatically caches the images, so the whole process only impacts performance the first time the images are viewed.
It currently supports the following vector image formats:
and the following output bitmap formats:
Dependencies
NoVector requires the following non-gem dependencies:
- RSVG binaries (namely
rsvg-convert
)
Using NoVector
Automatic
The primary method of using NoVector is through a simple JQuery script and a helper tag in your views. To use this method, simply write
<%= vector_tag asset, options %>
The asset
and options
arguments work precisely the same way they do for image_tag
. In addition you will need to include novector.js.coffee
in your applications's JavaScript. The recommended way of doing this is adding the following line in your application.js
, at some place after the inclusion of JQuery:
//= require novector
Also, you will need to mount the NoVector engine in the default location by adding the following in your routes.rb
:
mount Novector::Engine => '/novector'
Manual
You can also use NoVector's SVG rendering facilities directly through the following url:
/novector/fallback.FORMAT?src=ASSET&width=WIDTH&height=HEIGHT
where FORMAT
is replaced with a supported bitmap format, ASSET
is replaced by a supported vector asset, WIDTH
is width in pixels, and HEIGHT
is height in pixels.
License
NoVector is released under the MIT license, which can be found in the MIT-LICENSE
file.