Last active
August 29, 2015 14:17
-
-
Save besimhu/3c7ae0b066b6beed1d96 to your computer and use it in GitHub Desktop.
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
// Markup | |
<img src="<?php echo $src; ?>" | |
alt="<?php echo $alt; ?>" | |
width="<?php echo $width; ?>" | |
height="<?php echo $height; ?>" /> |
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
/** | |
* Pull image through object/array. | |
* | |
* This method is similar to pulling through the WP ID function. You do | |
* end up getting access to more object information, however it's quite a bit | |
* more writing you have to do. | |
* | |
* http://www.advancedcustomfields.com/resources/image/ | |
*/ | |
// Pull image from ACF field. | |
$image = get_field('image_field'); | |
// Pull object data. | |
$url = $image['url']; | |
$title = $image['title']; | |
$alt = $image['alt']; | |
$caption = $image['caption']; | |
// Define image size through crop. | |
$size = 'thumbnail'; | |
$src = $image['sizes'][ $size ]; | |
$width = $image['sizes'][ $size . '-width' ]; | |
$height = $image['sizes'][ $size . '-height' ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment