Created
May 23, 2019 04:35
-
-
Save seothemes/b4d4b5e6443d67f22f4966ce22b9e6eb to your computer and use it in GitHub Desktop.
Set default fallback image on archives in 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 | |
add_filter( 'genesis_get_image_default_args', 'prefix_set_image_fallback' ); | |
/** | |
* Set default fallback image on archives. | |
* | |
* @since 1.0.0 | |
* | |
* @param array $args Default image args. | |
* | |
* @return array | |
*/ | |
function prefix_set_image_fallback( $args ) { | |
if ( ! isset( $args['context'] ) ) { | |
return $args; | |
} | |
$id = '1381'; // <-- Change this value. | |
$html = wp_get_attachment_image( $id, $args['size'], false, $args['attr'] ); | |
$url = wp_get_attachment_image_src( $id, $args['size'], false ); | |
$args['fallback'] = [ | |
'url' => $url, | |
'html' => $html, | |
]; | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment