Log1x / sage-svg

A simple package for using inline SVGs with Sage 10.

Home Page:https://github.com/log1x/sage-svg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help with SVG path for typical WP setup

djmtype opened this issue · comments

Relative path (with dot notation) – resolves to app/themes/<your theme>/dist/images/logo.svg by default
@svg('images.logo')

Using Sage 10, I have a typical Wordpress setup where all my svgs live in wp-content/themes/<my-sage-theme>/resources/images/svg/*.svg. Upon build, all images including svgs get dumped into public, at the root for some reason, not inside an images directory.

With that said, what would be the relative path? Is it relative to production or development?

I tried @svg('resources/images/svg/my-icon') and @svg('my-icon') – neither work.

The plugin doesn't seem to be working for me. Example, if I type out @svg() in a blade template without any parameters, I don't get any PHP errors – it just prints out in plain text.

This seems to work: {{ get_svg('svg.logo') }}
But not this: @svg('svg.logo')

Sorry for the late reply.

Did you try wp acorn optimize:clear to clear view cache?

commented

Sorry for the late reply.

Did you try wp acorn optimize:clear to clear view cache?

This fixed it for me. Thanks.

@Log1x Running wp acorn optimize:clear via wp cli didn't seem to work for me.

I can't tell if the command was successful either as I'm using Local (by Flywheel) on an ARM Mac, but the application is written for Intel.

❯ wp acorn optimize:clear
Failed loading /Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.4.1+18/bin/darwin/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so:  dlopen(/Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.4.1+18/bin/darwin/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so, 0x0009): tried: '/Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.4.1+18/bin/darwin/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))

Warning: PHP Startup: Unable to load dynamic library '/Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.4.1+18/bin/darwin/lib/php/extensions/no-debug-non-zts-20190902/imagick.so' (tried: /Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.4.1+18/bin/darwin/lib/php/extensions/no-debug-non-zts-20190902/imagick.so (dlopen(/Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.4.1+18/bin/darwin/lib/php/extensions/no-debug-non-zts-20190902/imagick.so, 0x0009): tried: '/Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.4.1+18/bin/darwin/lib/php/extensions/no-debug-non-zts-20190902/imagick.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))), /opt/homebrew/Cellar/php@7.4/7.4.30/lib/php/20190902//Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.4.1+18/bin/darwin/lib/php/extensions/no-debug-non-zts-20190902/imagick.so.so (dlopen(/opt/homeb in Unknown on line 0
Compiled views cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches cleared successfully!

{{ get_svg('svg.logo') }} no longer seems to work with Sage 10.2 either. Now this is the correct implementation: {{ get_svg('images.svg.logo') }}. Sage seems to dump the svg directory into images by default, so they have to correspond. I'm sure there's some Laravel or Bud workaround, but that's perfectly fine.

@svg('images.svg.logo') now seems to work as well after clearing the acorn cache with wp acorn optimize:clear, I think.