Skip to content

Instantly share code, notes, and snippets.

@skkim7821
Last active November 24, 2017 07:10
Show Gist options
  • Save skkim7821/f16262c1cb58282057835e81c1e3980a to your computer and use it in GitHub Desktop.
Save skkim7821/f16262c1cb58282057835e81c1e3980a to your computer and use it in GitHub Desktop.
// acf/includes/api/api-helpers.php
function acf_get_simple_attachment( $post ) {
// post
$post = get_post($post);
if( !$post ) return false;
$sizes = ['thumbnail', 'medium', 'large', 'full'];
// vars
$id = $post->ID;
$thumb_id = $id;
$a = [];
// sizes
if( $thumb_id ) {
foreach( $sizes as $size ) {
$src = wp_get_attachment_image_src( $thumb_id, $size );
$a[ $size ] = [$src[0], $src[1], $src[2], $src[3]];
}
}
// return
return $a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment