Skip to content

Instantly share code, notes, and snippets.

@someguy9
Created January 27, 2023 21:44
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 someguy9/06646c2deb20ac3b44bff8388f81ca1e to your computer and use it in GitHub Desktop.
Save someguy9/06646c2deb20ac3b44bff8388f81ca1e to your computer and use it in GitHub Desktop.
Overwrite the default fallback image https://mightyshare.io/
<?php
// Overwrite MightyShare fallback image
function mightyshare_overwrite_fallback_image( $template_options ) {
var_dump(get_post_meta( $template_options['ID'], 'mightyshare_enabled', true ));
if ( get_post_thumbnail_id($template_options['ID']) !== $template_options['background'] && empty( get_post_meta( $template_options['ID'], 'mightyshare_background', true ) ) ) {
$template_options['background'] = 'https://images.unsplash.com/photo-1674757273875-e47dbfbda82c?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2831&q=80';
}
return $template_options;
}
add_filter( 'mightyshare_filter_post', 'mightyshare_overwrite_fallback_image', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment