| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Featured Image in Content |
| 4 |
* Plugin URI: http://celloexpressions.com/plugins/featured-image-in-content |
| 5 |
* Description: If you switch to a theme that doesn't show featured images on single posts, activate this plugin to show them in the content area. |
| 6 |
* Version: 1.0 |
| 7 |
* Author: Nick Halsey |
| 8 |
* Author URI: http://celloexpressions.com/ |
| 9 |
* Tags: featured image, post thumbnail |
| 10 |
* License: GPL |
| 11 |
|
| 12 |
===================================================================================== |
| 13 |
Copyright (C) 2015 Nick Halsey |
| 14 |
|
| 15 |
This program is free software; you can redistribute it and/or |
| 16 |
modify it under the terms of the GNU General Public License |
| 17 |
as published by the Free Software Foundation; either version 2 |
| 18 |
of the License, or (at your option) any later version. |
| 19 |
|
| 20 |
This program is distributed in the hope that it will be useful, |
| 21 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 |
GNU General Public License for more details. |
| 24 |
|
| 25 |
You should have received a copy of the GNU General Public License |
| 26 |
along with WordPress; if not, write to the Free Software |
| 27 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 28 |
===================================================================================== |
| 29 |
*/ |
| 30 |
|
| 31 |
add_filter( 'the_content', 'featured_image_in_content_add_to_content' ); |
| 32 |
function featured_image_in_content_add_to_content( $content ) { |
| 33 |
if ( is_singular() && has_post_thumbnail() ) { |
| 34 |
return get_the_post_thumbnail( null, 'large' ) . $content; |
| 35 |
} else { |
| 36 |
return $content; |
| 37 |
} |
| 38 |
} |