Could it be setup to pull an image via a custom field?
Sure that’s possible.
The code will look something like this:
add_filter( 'post_thumbnail_html', 'my_post_thumbnail_fallback', 20, 5 );
function my_post_thumbnail_fallback( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
$fallback_image = get_field('fallback_image');
if ( empty( $html ) ) {
$html = sprintf( '<img src="%1$s" alt="%2$s" itemprop="image" class="%3$s" />',
WPSP_Resize( $fallback_image, $image_atts[ 'width' ], $image_atts[ 'height' ], $image_atts[ 'crop' ], true, $image_atts[ 'upscale' ] )
esc_attr( the_title() ),
$settings[ 'image_alignment' ]
);
}
return $html;
}
The fallback_image
within get_field('fallback_image')
is basically the slug of the fallback image custom field. This is assuming you’re using ACF.