Skip to content

Commit

Permalink
Change default configs so that WebP is enabled and SVG is disabled by…
Browse files Browse the repository at this point in the history
… default
  • Loading branch information
markgibbons25 committed Feb 26, 2020
1 parent cae0b46 commit 197737a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
See the file type patches for the entries for this pipeline.
-->
<dianogaOptimize>
<!-- Checks the context site enableDianoga attribute.
Also works for SXA sites - no config necessary just set that attribute in the Site Grouping item. -->
<processor type="Dianoga.Processors.Pipelines.DianogaOptimize.DisableDianogaForSite, Dianoga" />
</dianogaOptimize>
</pipelines>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<processor type="Dianoga.Invokers.GetMediaStreamSync.OptimizeImage, Dianoga" />
</getMediaStream>

<getMediaStream>
<!-- Remove this if you are not using SVG support -->
<!-- Enable this if you are using SVG optimizers -->
<!--<getMediaStream>
<processor type="Dianoga.Svg.Pipelines.GetMediaStream.SvgIgnorer, Dianoga">
<!-- allow SVGs to be optimized synchronously before the ignorer aborts the pipeline -->
--><!-- allow SVGs to be optimized synchronously before the ignorer aborts the pipeline --><!--
<SynchronouslyOptimizeSvgs>true</SynchronouslyOptimizeSvgs>
</processor>
</getMediaStream>
</getMediaStream>-->
</pipelines>
</sitecore>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
<!--
Configures Dianoga to support SVG

By default this does not run any optimizer over SVGs, because SVGO, which seems to be the de facto library,
requires Node.js and that isn't something that can ship with a NuGet package. See Dianoga.Svg.SVGO.config.disabled
for directions to install and enable SVGO, if you want to use that to optimize the files as well.

Without SVGO, this patch file will enable:
* Storing SVGs in the media library without issue
* Gzipping SVGs that are served from the media library (a very good optimization since SVG = XML and is thus highly compressible)

What this does not enable:
* Using SVGs in rich text editors
* Rendering SVGs using field renderer that include height and width attributes on their <img> tag (note: you don't want this on responsive sites anyway)
* If you care about the above and want to maintain the hacks needed to enable it, see http://sitecorecorner.com/2015/11/23/sitecore-svg-support/

If you are enabling the SVGO optimiser, you'll need Node.js so you can restore the svgo dependencies.
1. Install the `Dianoga.svgtools` NuGet package
2. Open a command prompt in `Dianoga Tools/SVGO/node_modules/svgo`
3. Run `npm install`
4. `Dianoga Tools/SVGO/node_modules/svgo/node_modules` are required for the operation of svgo, so they will need to be copied to your website

Props:
SVG mime type config courtesy of Richard Seal, https://community.sitecore.net/developers/f/8/t/1670
SVG compression courtesy of Anders Laub, https://laubplusco.net/compress-svg-images-sitecore-media-library/
Expand All @@ -22,8 +15,9 @@
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<!-- Enable serving SVG from the media library -->
<mediaLibrary>
<!-- Enable serving SVG from the media library.
Newer versions of Sitecore have this already so check your version and enable as necessary -->
<!--<mediaLibrary>
<mediaTypes>
<mediaType name="SVG image" extensions="svg">
<mimeType>image/svg+xml</mimeType>
Expand All @@ -32,7 +26,7 @@
<versionedTemplate>system/media/versioned/image</versionedTemplate>
</mediaType>
</mediaTypes>
</mediaLibrary>
</mediaLibrary>-->

<!-- INITIALIZE DIANOGA SVG OPTIMIZATION -->
<pipelines>
Expand Down
6 changes: 3 additions & 3 deletions src/Dianoga/Dianoga.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<Compile Include="WebP\WebPThumbnailGenerator.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Default Config Files\Dianoga.WebP.config.disabled" />
<None Include="Default Config Files\Dianoga.WebP.config" />
<None Include="Dianoga Tools\jpegoptim-windows\COPYING.txt" />
<None Include="Dianoga Tools\jpegoptim-windows\COPYRIGHT.txt" />
<None Include="Dianoga Tools\jpegoptim-windows\jpegoptim.exe" />
Expand Down Expand Up @@ -110,10 +110,10 @@
<None Include="Default Config Files\Dianoga.Strategy.MediaCacheAsync.config">
<SubType>Designer</SubType>
</None>
<None Include="Default Config Files\Dianoga.config">
<None Include="Default Config Files\Dianoga.DisableForSites.config">
<SubType>Designer</SubType>
</None>
<None Include="Default Config Files\Dianoga.Svg.config">
<None Include="Default Config Files\Dianoga.Svg.config.disabled">
<SubType>Designer</SubType>
</None>
<None Include="Dianoga.nuspec" />
Expand Down

0 comments on commit 197737a

Please sign in to comment.