Home › Forums › Feature Requests › File field type: Option to return SVG as code › Reply To: File field type: Option to return SVG as code
God! It´s a bit embarrassing when you get the answer seconds after posting the question. But instead of removing it, I´ll just leave it here as it might help someone else, just like arleym´s post helped me.
Arleym was using a file field. I am using an image field. And I need it to be like that for reasons that go beyond this topic. (obs: wordpress does not support svg in the media library natively).
Having said that, it wasn´t working because my image field was set to return the object array while it MUST be set to return the URL, instead.
So the intial code on my previous comment was correct and after changing the value returned by the image field it now works!
<?php $svgImg = get_field('my_custom_field', $term, 'option'); ?>
<?php echo file_get_contents( $svgImg ); ?>
Hope this may help somebody else.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.