Skip to content

Instantly share code, notes, and snippets.

@alenabdula
Created May 16, 2016 15:24
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 alenabdula/3c16d3c370e9772eb9c224ad8b13312a to your computer and use it in GitHub Desktop.
Save alenabdula/3c16d3c370e9772eb9c224ad8b13312a to your computer and use it in GitHub Desktop.
<?php
/**
* File field returning ID
*/
if ( get_post_meta($post->ID, 'ENTER_KEY', true) ) {
$id = $cfs->get('ENTER_KEY');
$src = wp_get_attachment_image_src($id, 'large');
$alt = get_post_meta($id, '_wp_attachment_image_alt', true);
echo '<img src="' . esc_url($src[0]) . '" alt="' . $alt . '">';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment