Viewing 10 replies - 1 through 10 (of 10 total)
  • @françois,

    This is possible using the ‘s2_html_email’ hook in the code and writing a little plugin. you’d proabbly need to use a preg_replace something like this (from StackExchange):

    $content = preg_replace("/<img[^>]+\>/i", "", $content);

    Thread Starter flandreau

    (@flandreau)

    Thank you mattyrob.

    I’m going to try, this will be my first plugin if I succeed 🙂

    Thnaks again for your great support.

    François

    Thread Starter flandreau

    (@flandreau)

    Hello mattyrob,

    As Im’ not a coder I tried something like this after reading your API page:

    function iv_s2_html_filter($message) {
    	$content = preg_replace("/<img[^>]+\>/i", "", $content);
    }
    add_filter('s2_html_email', 'iv_s2html_filter');

    But of course it does nothing. Could you check what is wrong in this code please?

    Thanks in advance.

    François

    @françois,

    That’s a good try for your first attempt at a plugin. There are 2 things you need to fix though, first the function takes the parameter $message but the function itself uses $content. They all need to be the same.

    Second, after processing and changing the content to remove the image tags you need to return that new content to the process that called it by adding this as the last line in the function:
    return $content;

    So, the changes will make the code look like this.

    function iv_s2_html_filter($content) {
    	$content = preg_replace("/<img[^>]+\>/i", "", $content);
    	return $content;
    }
    add_filter('s2_html_email', 'iv_s2html_filter');

    Thread Starter flandreau

    (@flandreau)

    Thank you for your explanation. But I still have the image in the email.

    Perhaps this is a parametter that is not the right one?

    @françois,

    I’ve just noticed another error. The function is called ‘iv_s2_html_filter’, but the callback in the add_filter line contains an extra underscore in the ‘s2_html’ part. These need to be identical. I tested after applying that fix and it worked fine for me.

    Thread Starter flandreau

    (@flandreau)

    ok I applied changes. But I have still the issue.

    In fact the first image we show in the post is the author avatar. This is managed with wp user avatar plugin. It is insertedwith a shortcode in the post. Perhaps the problem come from this?

    Thread Starter flandreau

    (@flandreau)

    It is finally working for me. Thanks a lot for this!!!!!

    @françois,

    Excellent. How did you fix the avatar issue?

    Thread Starter flandreau

    (@flandreau)

    well in fact I made another mistake in the code. there was no other issue

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Subscribe2] Get ride of image in {POST}’ is closed to new replies.