Support

Account

Home Forums Feature Requests File field type: Option to return SVG as code Reply To: File field type: Option to return SVG as code

  • I was looking for this exact answer! Thanks! However, I need to output the svg for each term in a taxonomy loop. When it comes to that, ACF requires the term variable to be passed on as a second parameter in get_field().

    So I tried this:

    <?php $svgImg = get_field('my_custom_field', $term, 'option'); ?>
    <?php echo file_get_contents( $svgImg ); ?>

    But I get this php error:

    “Warning: “file_get_contents() expects parameter 1 to be a valid path”

    Seems like it´s not an issue related to the order of the parameters as when I swap $term and option, it makes WP blind to what term I´m referring to:

    “Warning: file_get_contents(): Filename cannot be empty”

    $term has been properly defined as I have tested it with:

    <?php $svgImg = get_field('my_custom_field', $term); ?>
    <img src="<?php echo $svgImg['url']? />">

    This last piece of code works. But the previous doesn´t.

    Can somebody help?