Created
December 16, 2014 10:58
-
-
Save erezLieberman/d28a745f6c44ac53803a to your computer and use it in GitHub Desktop.
allow svg in acf image field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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