Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Last active October 10, 2015 22:58
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatch/3764381 to your computer and use it in GitHub Desktop.
Save jaredatch/3764381 to your computer and use it in GitHub Desktop.
Customize image size used in the loop by Genesis
<?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