Last active
August 29, 2015 14:17
-
-
Save besimhu/83c4a81b39a274057646 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 Sample | |
<img src="<?php echo $image[0]; ?>" | |
width="<?php echo $image[1]; ?>" | |
height="<?php echo $image[2]; ?>" | |
alt="<?php echo $image_alt; ?>" /> | |
// Markup Sample (Media Query Sync) | |
<figure> | |
<img class="responsive" | |
src="<?php echo $media_sml[0]; ?>" | |
data-mq-large-src="<?php echo $media_lrg[0]; ?>" | |
width="<?php echo $media_lrg[1]; ?>" | |
height="<?php echo $media_lrg[2]; ?>" | |
alt="<?php echo $media_alt; ?>" /> | |
<figcaption> | |
<?php echo $media_alt; ?> | |
</figcaption> | |
</figure> |
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
/** | |
* Based off of image ID. | |
* | |
* You can use this method to pull in several different crops for responsive. | |
* The crop can be custom, or one of WP default ones, or leave empty. | |
* | |
* wp_get_attachment_image_src( $attachment_id, $size, $icon ) | |
* http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src | |
*/ | |
// Define variables | |
$image_id = $field['custom_filed']; | |
$image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true ); | |
$image = wp_get_attachment_image_src( $image_id, 'crop_name' ); | |
// Other ways to pull in ID. | |
wp_get_attachment_image_src( get_post_thumbnail_id(), 'crop_name' ); | |
wp_get_attachment_image_src( get_field('image_field'), 'crop_name' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment