Depending on configuration, this add-on requires webserver URL rewrite support!
SVG Template
Depending on configuration, this add-on requires webserver URL rewrite support!
Allows SVG (Scalable Vector Graphics) images to be stored as templates. This creates a new svg.php file in the XF root directory.
To generate a link to an SVG template (The template must have .svg at the end of the name!) ;
Under Board information, if "Use Full Friendly URLs" (useFriendlyUrls) is set the URL generated is :
Otherwise
Render to PNG
Rendering SVGs to PNGs requires external support, and depending on OS this may result in odd limitations or poor rendering.
php-imagick support
It is not recommended to use Imagick if it can be helped!
Ubuntu (using launchpad.net PPA);
Note; some distro's require libmagickcore-6.q16-3-extra to be installed to enable SVG support.
Older versions of Imagick have poor SVG support, on top of Imagick's poor security reputation.
CLI support
This is a generic escape hatch to plug in arbitrary png conversion, using proc_open in php.
Configure Render using proc_open option with;
{sourceFile} is the source SVG written as a temp file {destFile} is the destination PNG file as a temp file
Alternatively input/output can be done via pipes
Note; template names are only alpha-numeric strings, which is enforced by validation before the CLI option is called
resvg CLI support
Example using resvg, configure CLI command with;
Precompiled binary
Pre-compiled linux x86_64 binary has been made available here. Compiled on CentOS 7, works on Ubuntu 18.04/20.04
Compiling
Compiling may bind to newer versions of glibc which can cause portability issues
Inkscape CLI support
Note; use snap as otherwise it is likely to have too old an instance !
Configure CLI PIPE command with;
Features
Conditional rendering SVGs to PNG (for CSS/LESS)
An example of conditional CSS to use the png over the svg for mobile clients
Explicit usage in templates;
XenForo 2 routing integration
While webserver rewrite rules are recommended, this add-on supports extending XenForo's routing system to provide zero-configuration support for SVG Templates
Nginx URL rewrite config
Apache URL rewrite config
Add the rule before the final index.php;
ie, should look similar to;
Version 2.2.0 - Maintainance update :
Require php 7+
Require XenForo 2.1+
Conform XF2.2 support
Minor php 7.0/7.1 compatibility fix
Version 2.2.1 - Bugfix update : Fix "Support SVG url's in XF routing layer" option
Version 2.2.2 : Minor code cleanup, avoid connecting to master redis instance to only connect to a replica instance on rendering cached output
Version 2.3.0 - Feature update :
Add basic validation that an SVG template should render correctly
Add an optimization pass for SVG's. Prunes pruning whitespace and nodes/attributes known to be safe to remove. Includes minifying any inline css.
Support LESS/CSS in SVG's <style> element.
Add option "Render SVG's as PNG for mobile devices", this supports rewriting calls to getSvgUrl from .svg to .png
Requires Brower Detection v2.1.0+ add-on
Requires updating webserver URL rewrite urls to support PNGs
Caching requires explicitly defining a caching context with the name "sv-svg-img" or "css".
Supports Imagick or CLI executables as a back-end to render SVGs to PNGs.
Using Imagick is not recommended
Example using resvg, as a CLI-executable back-end;
This requires compiling using Rust, or use the pre-compiled linux x86_64 binary here.
Compiling can be done with;
Version 2.3.2 - Bugfix update
Require Standard Lib by Xon v1.1.0+
Force usage of global functions so php can optimize them into special bytecode instead of function calls
Fix disabling generating png links if svg => png is not configured
Improve installer to report svg => svg conditions which can block usage
Use "canonical" URL before XF2.2.3 as "full" doesn't work as expected in all contexts
Version 2.3.3 - Maintenance update : Reject attempting to save an SVG template with no elements
Version 2.3.4 - Maintenance update : Support
Version 2.3.5 - Maintenance update :
Work-around for non-desirable caching behaviour when CloudFlare (or similar) is forced to cache svg.php output
Prevent polluting of caches if the time-stamp is in the future
Version 2.4.1 - Maintenance update :
Require XenForo 2.2+
Require StandardLib v1.11.0+
Improve support for rendering templates in the mail & api contexts by correctly injecting template filters/functions into multiple rendering contexts
Compat fix when zlib output compression is enabled for PHP8.0.17+/PHP8.1.4+
Version 2.4.2 - Bugfix update :
Fix "XFCP_TemplaterHelper not found" error when upgrading the StandardLib add-on via the GUI
If this has happened, upload the files for this add-on. Then rebuild StandardLib add-on, then run the updater this add-on.
Version 2.4.3 - Bugfix update :
Fix issue using
Fix for race condition when creating temp files when encoding svg => png using resvg.
Update README.md to link to updated precompiled binary for resvg (v0.14.1 => v0.23.0)
Version 2.4.4 - Maintenance update : Improve error messages when saving invalid SVGs as templates.
Version 2.4.5 Bugfix update : Compatibility update with SV/StandardLib v1.14+, still compatible with SV/StandardLib v1.11+
Version 2.4.6 Bugfix update :
- Fix template validation ran on the master style instead of the current selected style
- Fix for upcoming XF2.3 compatibility, as Doctrine Cache been documented as being removed.
Version 2.4.8 - Bugfix update :
- Fix error running "xf:rebuild-master-data" when the exact template directory structure is missing and the SVG template is the first template compiled for that style.
- Fix possible compatibility issues with other add-ons extending SV/StandardLib's template helper code
Version 2.4.9 - Bugfix update :
- Fix SVG template validation was broken which could result in preventing adding a language or style from working correctly (or rebuilding master data)
Version 2.5.0 - Maintenance update :
This add-on is now avaliable on atelieraphelion.com
Version 2.5.1 - Bugfix update :
- Fix internal server error being generated instead of a 404 when requesting an invalid svg.
Version 2.5.2 - Bugfix update :
- Fix "[E_DEPRECATED] strlen(): Passing null to parameter #1 ($string) of type string is deprecated" when attempting to save a new template with an invalid name
Version 2.6.0; XF2.3 Compatibility update
- Fix XF2.3 style variations support for getSvgUrl() in style properties
SVG Template
Depending on configuration, this add-on requires webserver URL rewrite support!
Allows SVG (Scalable Vector Graphics) images to be stored as templates. This creates a new svg.php file in the XF root directory.
To generate a link to an SVG template (The template must have .svg at the end of the name!) ;
Code:
You must log in to view
(1 lines)
Under Board information, if "Use Full Friendly URLs" (useFriendlyUrls) is set the URL generated is :
Code:
You must log in to view
(1 lines)
Code:
You must log in to view
(1 lines)
Render to PNG
Rendering SVGs to PNGs requires external support, and depending on OS this may result in odd limitations or poor rendering.
php-imagick support
It is not recommended to use Imagick if it can be helped!
Ubuntu (using launchpad.net PPA);
Code:
You must log in to view
(2 lines)
Older versions of Imagick have poor SVG support, on top of Imagick's poor security reputation.
CLI support
This is a generic escape hatch to plug in arbitrary png conversion, using proc_open in php.
Configure Render using proc_open option with;
Code:
You must log in to view
(1 lines)
{sourceFile} is the source SVG written as a temp file {destFile} is the destination PNG file as a temp file
Alternatively input/output can be done via pipes
Note; template names are only alpha-numeric strings, which is enforced by validation before the CLI option is called
resvg CLI support
Example using resvg, configure CLI command with;
Code:
You must log in to view
(1 lines)
Precompiled binary
Pre-compiled linux x86_64 binary has been made available here. Compiled on CentOS 7, works on Ubuntu 18.04/20.04
Compiling
Compiling may bind to newer versions of glibc which can cause portability issues
Code:
You must log in to view
(5 lines)
Inkscape CLI support
Note; use snap as otherwise it is likely to have too old an instance !
Code:
You must log in to view
(1 lines)
Configure CLI PIPE command with;
Code:
You must log in to view
(1 lines)
Features
Conditional rendering SVGs to PNG (for CSS/LESS)
An example of conditional CSS to use the png over the svg for mobile clients
LESS:
You must log in to view
(17 lines)
Explicit usage in templates;
XML:
You must log in to view
(9 lines)
While webserver rewrite rules are recommended, this add-on supports extending XenForo's routing system to provide zero-configuration support for SVG Templates
Nginx URL rewrite config
NGINX:
You must log in to view
(5 lines)
Apache URL rewrite config
Add the rule before the final index.php;
APACHECONF:
You must log in to view
(1 lines)
APACHECONF:
You must log in to view
(12 lines)
Require php 7+
Require XenForo 2.1+
Conform XF2.2 support
Minor php 7.0/7.1 compatibility fix
Version 2.2.1 - Bugfix update : Fix "Support SVG url's in XF routing layer" option
Version 2.2.2 : Minor code cleanup, avoid connecting to master redis instance to only connect to a replica instance on rendering cached output
Version 2.3.0 - Feature update :
Add basic validation that an SVG template should render correctly
Add an optimization pass for SVG's. Prunes pruning whitespace and nodes/attributes known to be safe to remove. Includes minifying any inline css.
Support LESS/CSS in SVG's <style> element.
Add option "Render SVG's as PNG for mobile devices", this supports rewriting calls to getSvgUrl from .svg to .png
Requires Brower Detection v2.1.0+ add-on
Requires updating webserver URL rewrite urls to support PNGs
Caching requires explicitly defining a caching context with the name "sv-svg-img" or "css".
Supports Imagick or CLI executables as a back-end to render SVGs to PNGs.
Using Imagick is not recommended
Example using resvg, as a CLI-executable back-end;
/usr/local/bin/resvg --quiet {sourceFile} {destFile}
This requires compiling using Rust, or use the pre-compiled linux x86_64 binary here.
Compiling can be done with;
Code:
You must log in to view
(5 lines)
Require Standard Lib by Xon v1.1.0+
Force usage of global functions so php can optimize them into special bytecode instead of function calls
Fix disabling generating png links if svg => png is not configured
Improve installer to report svg => svg conditions which can block usage
Use "canonical" URL before XF2.2.3 as "full" doesn't work as expected in all contexts
Version 2.3.3 - Maintenance update : Reject attempting to save an SVG template with no elements
Version 2.3.4 - Maintenance update : Support
getSvgUrlAs('tenplate.svg', 'png')
in style propertiesVersion 2.3.5 - Maintenance update :
Work-around for non-desirable caching behaviour when CloudFlare (or similar) is forced to cache svg.php output
Prevent polluting of caches if the time-stamp is in the future
Version 2.4.1 - Maintenance update :
Require XenForo 2.2+
Require StandardLib v1.11.0+
Improve support for rendering templates in the mail & api contexts by correctly injecting template filters/functions into multiple rendering contexts
Compat fix when zlib output compression is enabled for PHP8.0.17+/PHP8.1.4+
Version 2.4.2 - Bugfix update :
Fix "XFCP_TemplaterHelper not found" error when upgrading the StandardLib add-on via the GUI
If this has happened, upload the files for this add-on. Then rebuild StandardLib add-on, then run the updater this add-on.
Version 2.4.3 - Bugfix update :
Fix issue using
getSvgUrl/[getSvgUrlAs
in style properties with a template without an extension would cause CSS to fail to renderFix for race condition when creating temp files when encoding svg => png using resvg.
Update README.md to link to updated precompiled binary for resvg (v0.14.1 => v0.23.0)
Version 2.4.4 - Maintenance update : Improve error messages when saving invalid SVGs as templates.
Version 2.4.5 Bugfix update : Compatibility update with SV/StandardLib v1.14+, still compatible with SV/StandardLib v1.11+
Version 2.4.6 Bugfix update :
- Fix template validation ran on the master style instead of the current selected style
- Fix for upcoming XF2.3 compatibility, as Doctrine Cache been documented as being removed.
Version 2.4.8 - Bugfix update :
- Fix error running "xf:rebuild-master-data" when the exact template directory structure is missing and the SVG template is the first template compiled for that style.
- Fix possible compatibility issues with other add-ons extending SV/StandardLib's template helper code
Version 2.4.9 - Bugfix update :
- Fix SVG template validation was broken which could result in preventing adding a language or style from working correctly (or rebuilding master data)
Version 2.5.0 - Maintenance update :
This add-on is now avaliable on atelieraphelion.com
- Require php 7.2+
- Require StandardLib v1.18.0+
- If using resvg support, recommend updating to v0.35.0.
Pre-compiled linux x86_64 binary has been made available here.
Compiled on CentOS 7, works on Ubuntu 18.04/20.04/22.04 - Document using resvg v0.35.0+ with "CLI - Pipe" mode, which avoid temporary files when converting SVGs to PNGs
Example using resvg v0.35.0+, configureCLI - Pipe
command with;
Code:
You must log in to view
(1 lines)
- Fix internal server error being generated instead of a 404 when requesting an invalid svg.
Version 2.5.2 - Bugfix update :
- Fix "[E_DEPRECATED] strlen(): Passing null to parameter #1 ($string) of type string is deprecated" when attempting to save a new template with an invalid name
Version 2.6.0; XF2.3 Compatibility update
- Requires StandardLib v1.19.0+
- If installed, requires Redis Cache 2.17.0+
- XF2.3 compatibility update
- php 8.4 compatibility fix
- Fix XF2.3 style variations support for getSvgUrl() in style properties
Attachments
-
addon-Xon-SvgTemplate-2.1.6.zip21.7 KB · Views: 0
-
addon-Xon-SvgTemplate-2.2.1.zip21.7 KB · Views: 0
-
addon-Xon-SvgTemplate-2.2.2.zip21.8 KB · Views: 0
-
addon-Xon-SvgTemplate-2.3.0.zip35.9 KB · Views: 0
-
addon-Xon-SvgTemplate-2.3.3.zip36.3 KB · Views: 0
-
addon-Xon-SvgTemplate-2.3.4.zip36.4 KB · Views: 0
-
addon-Xon-SvgTemplate-2.3.5.zip36.6 KB · Views: 0
-
addon-Xon-SvgTemplate-2.4.1.zip35.6 KB · Views: 0
-
addon-Xon-SvgTemplate-2.4.2.zip35.7 KB · Views: 0
-
addon-Xon-SvgTemplate-2.4.3.zip35.9 KB · Views: 0
-
addon-Xon-SvgTemplate-2.4.4.zip36.1 KB · Views: 0
-
addon-Xon-SvgTemplate-2.4.5.zip36.2 KB · Views: 0
-
addon-Xon-SvgTemplate-2.4.6.zip36.2 KB · Views: 0
-
addon-Xon-SvgTemplate-2.4.8.zip36.4 KB · Views: 0
-
addon-Xon-SvgTemplate-2.4.9.zip36.5 KB · Views: 0
-
addon-Xon-SvgTemplate-2.5.0.zip38.9 KB · Views: 0
-
addon-Xon-SvgTemplate-2.5.1.zip36.6 KB · Views: 0
-
addon-Xon-SvgTemplate-2.5.2.zip36.6 KB · Views: 0
-
addon-Xon-SvgTemplate-2.6.0.zip36 KB · Views: 0
-
addon-Xon-SvgTemplate-2.6.1.zip36.2 KB · Views: 0