Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created March 19, 2015 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/1019f3ade7e1e6e0e97f to your computer and use it in GitHub Desktop.
Save tripflex/1019f3ade7e1e6e0e97f to your computer and use it in GitHub Desktop.
Output image thumbnail with link to full size image
<?php
$sample_gallery_images = get_custom_field( 'sample_gallery_images' );
// If field value is empty don't output anything
if( ! empty( $sample_gallery_images ) && function_exists( 'job_manager_get_resized_image' ) ){
// If it's an array that means there are multiple images
if( is_array( $sample_gallery_images ) ){
foreach( $sample_gallery_images as $gallery_image ){
$thumbnail_image = job_manager_get_resized_image( $gallery_image, 'thumbnail' );
// 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="' . $thumbnail_image . '" class="some_custom_class" /></a><br />';
}
// Otherwise it's a single image URL
} else {
$thumbnail_image = job_manager_get_resized_image( $sample_gallery_images, 'thumbnail' );
// This outputs an image with a link to the image itself
echo '<a href="' . $sample_gallery_images '" target="_blank"><img src="' . $thumbnail_image . '" class="some_custom_class" /></a>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment