wp-featherlight icon indicating copy to clipboard operation
wp-featherlight copied to clipboard

Reconsider adding WebP support

Open cessez-le-feu opened this issue 4 years ago • 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:

  • WordPress 5.8 adds WebP support https://make.wordpress.org/core/2021/06/07/wordpress-5-8-adds-webp-support/

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!

cessez-le-feu avatar Sep 12 '21 00:09 cessez-le-feu

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 ) {

jcamp avatar Oct 14 '22 10:10 jcamp

https://github.com/cipherdevgroup/wp-featherlight/pull/74

Azragh avatar Feb 08 '23 13:02 Azragh