Skip to content

Instantly share code, notes, and snippets.

@bmodena
Created February 18, 2015 16:30
Show Gist options
  • Save bmodena/30284c6eaf6d16dac847 to your computer and use it in GitHub Desktop.
Save bmodena/30284c6eaf6d16dac847 to your computer and use it in GitHub Desktop.
Advanced Custom Field - Image Field - Get Cropped image
/*
** ACF Image Helper
**
** @Param $imageId: int - image ID you are using
** @Param $size: string - image size you want to retrieve
** @Param $fieldName: string (optional) - name of the image field within the repeater
** @Return Array - image url and alt text for image
**
*/
function tmbr_get_cropped_image( $imageId, $size ) {
$image = array();
$imageArr = wp_get_attachment_image_src( $imageId, $size );
$image['url'] = $imageArr[0];
$image['alt'] = tmbr_get_alt( $imageId );
return $image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment