Created
February 18, 2015 16:30
-
-
Save bmodena/30284c6eaf6d16dac847 to your computer and use it in GitHub Desktop.
Advanced Custom Field - Image Field - Get Cropped image
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
/* | |
** 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