Last active
August 29, 2015 14:17
-
-
Save tripflex/4d2d84815689daa033be to your computer and use it in GitHub Desktop.
Output multiple file upload images with links
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 | |
$sample_gallery_images = get_custom_field( 'sample_gallery_images' ); | |
// If field value is empty don't output anything | |
if( ! empty( $sample_gallery_images ) ){ | |
// If it's an array that means there are multiple images | |
if( is_array( $sample_gallery_images ) ){ | |
foreach( $sample_gallery_images as $gallery_image ){ | |
// This outputs an image with a link to the image itself with a line break after each image | |
echo '<a href="' . $gallery_image '" target="_blank"><img src="' . $gallery_image . '" class="some_custom_class" /></a><br />'; | |
} | |
// Otherwise it's a single image URL | |
} else { | |
// This outputs an image with a link to the image itself | |
echo '<a href="' . $sample_gallery_images '" target="_blank"><img src="' . $sample_gallery_images . '" class="some_custom_class" /></a>'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment