CategoryIcon adds icons to links on category pages, where image name = target link (category name). Added images have the class name "cicon-image" by default.
Settings
Available through window.fng.cicon:
- option - defaults - acceptable values
- description
- debug - false - true/false
- some info spammed to console
- restrict - true - true/false
- run the script only in category: namespace
- ext - .png - string
- image format (extension)
- cls - cicon-image - string
- image class, for styling purposes
- scale - /scale-to-width-down/50 - string
- add scaling request to image path (reduces bandwidth usage); last part (50) - size in pixels; use scale="" to disable
- iprepend - "" - string
- prepend text to image name; result: string+categoryname+ext
- iappend - "" - string
- append text to image name; result: categoryname+string+ext
- tprepend - "" - string
- prepend text (span with class "cicon-prepend") to image tag; result: string<img ...>
- tappend - "" - string
- append text (span with class "cicon-append") to image tag; result: <img ...>string
Example
//creates settings object
window.fng = $.extend(window.fng, {cicon:{}});
//sets file extension to .svg
window.fng.cicon.ext = '.svg';
//prepends 'Map ' to applicable files (e.g. for the 'Earth' category filename would be 'Map Earth')
window.fng.cicon.iprepend = 'Map ';
//requests downscaling to 50px
window.fng.cicon.scale = '/scale-to-width-down/50';
With the settings above, the script will search for files with the name "Map link.svg", where "link" is the original name of the category, and add them to the corresponding categories.
Notes
- Double redirects will not resolved.
- Image and text are not styled by default. Use classes above to add styling.
- Settings are supposed to be added somewhere in common.js. The script itself needs to be added in ImportJS.
Installation