Last active
October 10, 2015 22:58
-
-
Save jaredatch/3764381 to your computer and use it in GitHub Desktop.
Customize image size used in the loop by Genesis
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
<?php | |
/** | |
* Customize image size used in the loop by Genesis | |
* | |
* @author Jared Atchison | |
* @link http://jaredatchison.com/code/ | |
* @param string $image_size | |
* @global array $wp_query | |
* @global int $loop_counter | |
* @return string | |
*/ | |
function ja_custom_loop_image_size( $image_size ) { | |
global $wp_query; | |
global $loop_counter; | |
$page = get_query_var( 'paged' ); | |
// If we are the first page of a post archive page, use the the | |
// 'featured' image size for the first post | |
if ( $loop_counter < 1 && $paged < 2 && get_post_type() == 'post' ) | |
$image_size = 'featured'; | |
// Use 'portfolio' image size on portfolio archive pages | |
if ( is_post_type_archive( 'portfolio' ) ) | |
$image_size = 'portfolio-small'; | |
return $image_size; | |
} | |
add_filter( 'genesis_pre_get_option_image_size', 'ja_custom_loop_image_size' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment