stefanledin / responsify-wp

The WordPress plugin that cares about responsive images.
http://responsifywp.com
GNU General Public License v2.0
52 stars 8 forks source link

lazy load with rwp_edit_generated_element #17

Open benjamingeorge opened 9 years ago

benjamingeorge commented 9 years ago

I tried adding your example filter for lazy loading. In my templates I use rwp_img() to get the picturefill markup but the [data-src] attribute isn't added. Is the rwp_edit_generated_element filter called when using rwp_img() or rwp_picture?

benjamingeorge commented 9 years ago

In rwp_functions.php you can add the filter methods and it seems to work.

function rwp_img( $id, $settings = null ) {
    $element = Picture::create( 'img', $id, $settings );
    if ( has_filter( 'rwp_edit_generated_element' ) ) {
        $element = apply_filters( 'rwp_edit_generated_element', $element );
    }
    return $element;    
}
stefanledin commented 9 years ago

Hi! Sorry for the late reply, I've turned off notification mails accidentally ;) No, you're right. The filter is not applied when calling rwp_img() or rwp_picture(). You might be able to use rwp_attributes() instead, but the filter should of course be applied here to.

Thanks for telling me about this :)