I'm building a WordPress theme which has an options panel. Within the options panel, admin can upload an icon which will appear in the footer.
When uploading an icon, admin will upload a SVG and PNG version to the media uploader (icon.svg and icon.png for example).
I'm displaying this icon on the front end like so:
<nav>
<?php if( have_rows('footer_icons', 'option') ): ?>
<ul>
<?php while( have_rows('footer_icons', 'option') ): the_row();
// Vars
$icon = get_sub_field('icon');
?>
<li>
<img src="<?php echo esc_url($icon); ?>" alt="icon" width="60" height="60">
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</nav>
Is there a way to feature detect and display an inline png fallback (icon.png) should the browser not support SVG? I know Modernizr offers SVG detection, but I couldn't see that it would offer this level of support.