Hot answers tagged

4

You can achieve this using the extraFileKinds config setting like this: 'extraFileKinds' => [ 'svg' => [ 'label' => 'SVG', 'extensions' => ['svg'], ], ], On your Asset field, check the "Restrict allowed file types?" checkbox, and select "SVG" from the list.


4

Half-bug, half side-effect/undesired behavior for SVG sanitization that got added in Craft 2.6.2982 for SVGs that use embedded data. The next release of Craft (post 2.6.2983) adds a sanitizeSvgUploads config setting (true by default) that you will be able to set to false to disable SVG sanitization.


2

Turns out, there was a bug in Smart Map which made this impossible. Fortunately, it's now fixed! As of Smart Map v2.4.2, it is possible to build more elaborate markers using a nested syntax for the markerOptions value. Try something like this... {% set options = { markerOptions: { icon: { url: '/path/to/svg/file', ...


2

Ok, think I know what's wrong – you want to select the first asset, but not its url. E.g. {{ svg(callout.icon.one()) }}


2

Are you placing the SVG into your web page within an IMG tag, by any chance? If so, try changing to an inline SVG instead. There are quite a few SVG features that don’t work unless you use inline SVG, and from memory links are one of them.


1

I would like to summarize the conclusion. In order to embed link on SVG image in Craft CMS website, inline SVG is the solution. It works with putting a source code into rich text field, like this; <figure style="width: 100%;"><object data="{{ image_url }}" type="image/svg+xml" width="100%"></object>&...


1

Perhaps, the config setting sanitizeSvgUploads could be of help. Whether Craft should sanitize uploaded SVG files and strip out potential malicious-looking content. https://craftcms.com/docs/3.x/config/config-settings.html#sanitizesvguploads


1

Because you are wrapping {{ entry.myCustomFieldValue }} in ', you are passing it as a string instead of its value, that's why you then see it as is in your result. Try: {{ svg('@webroot/_dist/stat/link-arrow.svg')|attr({ stroke: entry.myCustomFieldValue }) }}


1

Gitignore had a line for Icon? which was causing the icon folder to not show up in git commit.


1

Actually, the resourceUrl() method doesn't care about the resource file's extension and is able to serve up SVGs (and any other filetype) just fine, so there must be something else wrong. Most likely, the path (i.e. cocktailrecipes/images/gin.svg) to the file isn't correct. If your plugin has the handle cocktailrecipes (all lowercase; the handle should be ...


1

Never used the plugin before, but from glancing at their docs, it looks like entry.icons.icon is what you're looking for. Any other properties on their SvgIconsModel should work as well.


Only top voted, non community-wiki answers of a minimum length are eligible