cipherdevgroup/wp-featherlight

Reconsider adding WebP support

cessez-le-feu opened this issue · 2 comments

Hello,

I think you should reconsider adding WebP support. The original ticket proposing WebP support was closed for the reason that, at the time, WordPress core didn’t allow WebP by default, and only one browser understood the format. However, the situation has completely changed since. See:

And actually, updating the "wp-featherlight" plugin to support WebP would be a child’s game. For my own site, I just replaced all occurrences of "bmp" with "webp" in the plugin’s code, and it worked!

jcamp commented

Just update "wpFeatherlight.js" and add "WebP" to the list of image types.

This function is in several places:

/**
	 * Checks href targets to see if a given anchor is linking to an image.
	 *
	 * @since  0.1.0
	 * @return mixed
	 */
	function testImages( index, element ) {
		return /(.png|.jpg|.jpeg|.gif|.tiff|.bmp|.webp)$/.test(
			$( element ).attr( 'href' ).toLowerCase().split( '?' )[0].split( '#' )[0]
		);
	}

Present in 3 files

js/wpFeatherlight.js
function testImages( index, element ) {

assets/plugin/js/wpFeatherlight.js
function testImages( index, element ) {

js/wpFeatherlight.pkgd.js
function testImages( index, element ) {