Created
June 27, 2016 19:37
-
-
Save anonymous/fae7604bb66b68d1415138a2e76f5d41 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
/** | |
* Grid Image Sizes | |
* | |
*/ | |
function be_grid_image_sizes() { | |
add_image_size( 'be_grid', 175, 120, true ); | |
add_image_size( 'be_feature', 570, 333, true ); | |
} | |
add_action( 'genesis_setup', 'be_grid_image_sizes', 20 ); | |
/** | |
* Grid Loop Featured Image | |
* | |
* @param string image size | |
* @return string | |
*/ | |
function be_grid_loop_image( $image_size ) { | |
global $wp_query; | |
$grid_args = be_grid_loop_pagination(); | |
if( ! $grid_args ) | |
return $image_size; | |
// Feature | |
if( ( ! $wp_query->query_vars['paged'] && $wp_query->current_post < $grid_args['features_on_front'] ) || ( $wp_query->query_vars['paged'] && $wp_query->current_post < $grid_args['features_inside'] ) ) | |
$image_size = 'be_feature'; | |
if( ( ! $wp_query->query_vars['paged'] && $wp_query->current_post > ( $grid_args['features_on_front'] - 2 ) ) || ( $wp_query->query_vars['paged'] && $wp_query->current_post > ( $grid_args['features_inside'] - 1 ) ) ) | |
$image_size = 'be_grid'; | |
return $image_size; | |
} | |
add_filter( 'genesis_pre_get_option_image_size', 'be_grid_loop_image' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment