• Hi there,

    This plugin seems to be awesome for image optimisation, especially when mobile performance is more and more taken into account for the SEO.

    Unfortunately, I’m not an expert. And I have red that the default plugin settings only take care of images related to the_content (TinyMCE if I understand correctly).

    What I expect to do is to add this an srcset attribute to ALL my images. This can be done by using the rwp_add_filters if I have properly understood. But I need some help in order to achieve this, like a proper exemple related to MY website in order to get started.

    My website : https://www.les-alternatives.com

    The different images displayed on my website will comes from 3 plugins :
    Justify Images Grid
    Custom Content Shortcode
    Grid FX

    Let’s say we’ll begin to add a rwp_add_filter for all images related to the Custom Content Shortcode plugin. An example of my “last product news” made with this plugin can be shown there : https://www.les-alternatives.com/jeu/moba/news-smite-battleground-of-the-gods/

    As you can see, even if the plugin uses standard WP function, and are generated directly inside the Tiny MCE Editor, no srcset attribute are set. Can you just gimme an example on how I can do to make your plugin work.

    Any help will be more than appreciated.

    PS : if you wanna give me an exemple for the Grid FX plugin, displayed on the welcome page here, you can do it too. It will be easier prob because Custom Content Shortcode is kinda specific.

    Regards.

    https://www.ads-software.com/plugins/responsify-wp/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author stefanledin

    (@stefanledin)

    Hi moxymore!
    The rwp_add_filters filter should be used if other plugins provides any filters for editing the content that they’re outputting. (Yeah I know, confusing to talk about a filter that handles filters…)

    Example:
    If Custom Content Shortcode had a filter called edit_output (which it hasn’t, this is an example), you could have done this:

    <?php
    function add_filters( $filters ) {
        $filters[] = 'edit_output';
        return $filters;
    }
    add_filter( 'rwp_add_filters', 'add_filters' );
    ?>

    RWP would then make any images coming through that filter responsive. This is a bit more advanced of course, but that’s how it works.
    But if the plugin doesn’t provide such filters, then you’re on your own. I’ve looked at Custom Content Shortcode and that plugin doesn’t have any filters. But it seems to be using shortcodes, which are “executed” after RWP. That’s the reason to why RWP isn’t doing anything with those images.

    One quick fix that worked for me is to change replace 10 with 12 on line 12 in this file: responsify-wp/includes/content_filter.php.
    It should look like this:

    add_filter( $filter, array( $this, 'filter_images' ), 12 );

    That makes RWP work together with CCS in my test. The two other plugins are premium ones, so I haven’t tried them.

    Thread Starter moxymore

    (@moxymore)

    Thank you for your answer, i really appreciate it!

    I think then it will be possible too for the 2 others plugins (JIG and Grid FX), because without looking at the php code, I have already looked a lot at the CSS generated and they both add some extrainfo. So, I’m just crossing the fingers.

    Tell me just one more thing : Is it possible to make my own plugin with these custom filters? Because honestly, I don’t like to touch core plugins’ files, which can be modified after each update.

    Thank you again.

    Bye.

    Plugin Author stefanledin

    (@stefanledin)

    I’ll add the change in the next update since it might be useful to others to. You can safely edit the core file ??
    The function that adds filters to RWP should be placed in your themes functions.php file.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘rwp_add_filters examples needed’ is closed to new replies.