Last active
May 27, 2017 18:13
-
-
Save GaryJones/7070243 to your computer and use it in GitHub Desktop.
Genesis: Stop archives from using first attached image as fallback when no featured image is set.
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 | |
// Don't include the above. | |
add_filter( 'genesis_get_image_default_args', 'prefix_stop_auto_featured_image' ); | |
/** | |
* Stop Genesis archives from using first attached image as fallback when no featured image is set. | |
* | |
* @param array $args Default image arguments. | |
* | |
* @return array Amended default image arguments. | |
*/ | |
function prefix_stop_auto_featured_image( $args ) { | |
if ( ! isset( $args['context'] ) || 'archive' !== $args['context'] ) | |
return $args; | |
$args['fallback'] = false; | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Gary, thank you for this! I modified this code to let me set a default fallback image of my choosing: https://gist.github.com/oncecoupled/1fa7de6b15e862a94b1f
I'm noticing that where my theme does a modified post image and uses genesis_get_image(), the attr and size are not being read in properly for my fallback image, only for my manually set featured images.
Is there something I'm missing that would make this work for both the set and fallback featured images, or is it not easily accomplished at this time?
Best,
Lauren