Thread Starter
jx25
(@jx25)
We’re using a plugin that helps – it assigns the attached image as the featured image.
However, the attached image show up again at the bottom of the post, as an inline image. Is there a way to do any of the following?:
1. Get rid of the inline image altogether
2. Reduce the size of the inline image to a very small thumbnail, embedded at the top/right of the post
Preferably #1?
It’s just that the image is so huge, redundant/unnecessary when your theme has a huge feature image already!
Thanks!
While Jetpack doesn’t offer that option, you could automatically remove featured images from the post content by filtering the_content in a separate plugin.
I haven’t tested it, but something like this could work:
/**
* Remove Featured Image from the post content.
*
* @see https://ww.wp.xz.cn/support/topic/2930158
*/
function jeherve_rm_featured_content( $content ) {
// Let's get info about the featured image first.
$post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id() );
// Let's build a pattern: our image, in an image tag
$image = sprintf(
'!<img.*?src="%s".*?/>!i',
$post_thumbnail[0]
);
// Remove the image from the post content.
$content = preg_replace( $image, '', $content );
return $content;
}
add_filter( 'the_content', 'jeherve_rm_featured_content' );
Thread Starter
jx25
(@jx25)
Thanks very much! I’m not a coder at all, so my layperson eyes sees symbols.
Could you tell me if I can copy & paste this somewhere?
I didn’t quite catch what filtering the_content in a separate plugin means.
What’s the name of the plugin?
Do I find/activate the plugin, then paste this code in it?
If so, where?
Thanks a lot.
Thread Starter
jx25
(@jx25)
Alright, got the answer, thanks!
Glad to hear you’re all set!
In general, it’s best to use functionality plugins for all snippets you need to add to an existing site. This plugin is usually a good start:
https://ww.wp.xz.cn/plugins/code-snippets/
Dear jx25 – I have the same requirement.
Can you please help?
1. Which plugin did you use to set the featured image in post by email.
2. How did you get rid of the pic from the post body?
Regards,
Raju.
whats the name of the plugin that will set image to feature images
whats the name of the plugin that will set image to feature images
I haven’t tested it, but it looks like this plugin is what you’re looking for:
https://ww.wp.xz.cn/plugins/wp-auto-featured-image/