kevinmcullen
Forum Replies Created
Viewing 1 replies (of 1 total)
-
I am trying to accomplish something similar, but I want to include a default fallback image. I’ve tried adding the following to my functions.php and can’t get it to work. Any suggestions?
If I add the else conditional directly to the plugin file, it works perfectly, but I can’t figure out how to accomplish it without modifying the original plugin.
function add_default_image_thumbnail( $output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class ) { if ( $image_size && has_post_thumbnail() && $include_link ) { $image = '<a class="image" href="' . get_permalink() . '">' . get_the_post_thumbnail( get_the_ID(), $image_size ) . '</a> '; } elseif( $image_size && has_post_thumbnail() ) { $image = '<span class="image">' . get_the_post_thumbnail( get_the_ID(), $image_size ) . '</span> '; } elseif( $image_size ) { $image = '<a class="image" href="' . get_permalink() . '">' . '<img width="740" height="400" src="http://mysite.com/placeholder.png" class="attachment-home-top size-home-top wp-post-image" alt="">' . '</a> '; }; $output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $title . $date . $excerpt . $content . '</' . $inner_wrapper . '>'; return $output; } add_filter( 'display_posts_shortcode_output', 'add_default_image_thumbnail', 10, 9 );- This reply was modified 8 years, 7 months ago by kevinmcullen.
Viewing 1 replies (of 1 total)