Skip to content

Instantly share code, notes, and snippets.

@erezLieberman
Created December 16, 2014 10:58
Show Gist options
  • Save erezLieberman/d28a745f6c44ac53803a to your computer and use it in GitHub Desktop.
Save erezLieberman/d28a745f6c44ac53803a to your computer and use it in GitHub Desktop.
allow svg in acf image field
<?php $image = get_sub_field('features_img');
if( !empty($image) ):
// vars
$url = $image['url'];
$title = $image['title'];
$alt = $image['alt'];
$caption = $image['caption'];
// thumbnail
$size = 'bigImg';
$thumb = $image['sizes'][ $size ];
$width = $image['sizes'][ $size . '-width' ];
$height = $image['sizes'][ $size . '-height' ];
$svgfile = simplexml_load_file($url);
$width_svg = substr($svgfile[width],0,-2);
$height_svg = substr($svgfile[height],0,-2);
?>
<div class="imgCont">
<img src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" width="<?php echo $width_svg; ?>" height="<?php echo $height_svg; ?>" />
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment