verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

Bug when sprite file only has one icon #37

Closed loweoj closed 4 years ago

loweoj commented 4 years ago

Description

I'm using the "icon sprites" feature with a file name icons-sprites.svg in my icon root. The sprite has only one <symbol>:

<svg xmlns="http://www.w3.org/2000/svg" class="hidden">
  <symbol id="example" aria-hidden="true" focusable="false" role="img" viewBox="0 0 25 44" xmlns="http://www.w3.org/2000/svg"><path .../></symbol>
</svg>

I get an error Illegal string offset '@id' in vendor/verbb/icon-picker/src/services/Service.php@145 because the length of the $files array is 1, and there's no index.

Simple fix for me (add an extra empty to the sprite as a placeholder for now while in development). Hopefully easy fix for you too (check length of $files array)

Thought you'd like to know. Cheers!

engram-design commented 4 years ago

Fixed in 1.1.7