kylereicks / picturefill.js.wp

A WordPress plugin to use Picturefill.js for image loading.
106 stars 10 forks source link

Bails out if the src ends with .svg #49

Closed thisislawatts closed 9 years ago

thisislawatts commented 10 years ago

Fixes #48

kylereicks commented 9 years ago

I like this idea. I'm just going to broaden it out a little bit. I'm going to add a new filter "picturefill_wp_process_this_image" that has a default value of true, and that will be passed the image DOM node and post HTML data to reference.

Conditionally excluding SVG could then be handled like this: ` add_filter('picturefill_wp_process_this_image', 'picturefill_wp_exclude_svg', 10, 3);

function picturefill_wp_exclude_svg($process, $image, $html){ if(preg_match('/.svg$/i', $image->getAttribute('src'))){ return false; } return $process; } `

This way we can exclude images conditionally, based on any of their attributes