Skip to content

Instantly share code, notes, and snippets.

@seothemes
Created May 23, 2019 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seothemes/b4d4b5e6443d67f22f4966ce22b9e6eb to your computer and use it in GitHub Desktop.
Save seothemes/b4d4b5e6443d67f22f4966ce22b9e6eb to your computer and use it in GitHub Desktop.
Set default fallback image on archives in Genesis
<?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