• Resolved jx25

    (@jx25)


    Hi Jeremy (or anyone who can help!)

    I posted that the attached images in Post by Email show up again at the bottom of the post as an inline image, and asked if there was a way to –

    *** Get rid of the inline image altogether ***

    Jeremy Herve said:

    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’ );

    My question is:
    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.

    https://ww.wp.xz.cn/plugins/jetpack/

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Super quick question/clarification/waiting to use plugin’ is closed to new replies.