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.