The solution to this problem is quick and easy. There’s a particular line in the minified code that must be revised by the developer to accommodate all image formats. However, for the immediate issue concerning WEBP images, a simple tweak is all that’s needed. This alteration can be applied to any image type that is not currently recognized by the file extension pattern in the regex. By updating this regex expression, we will resolve the issue until a more permanant fix can be implemented.
Original Line Of Code for Featherlight jQuery Plugin:
image:{regex:/\.(png|jpg|jpeg|gif|tiff?|bmp|svg)
WEB Image Fix For Featherlight jQuery Plugin:
image:{regex:/\.(png|jpg|jpeg|gif|tiff?|bmp|svg|webp)
The jumbled text you’re seeing is occurring because the current settings do not accommodate WEBP images or any other image formats that the search tool—referred to as a regex—cannot recognize. However, you can fix this by applying the solution above in the featherlight minified code, enabling your Featherlight jQuery plugin to function correctly with your image file extension.
A More Advanced Fix:
This fix below actually remove the use of REGEX and uses the mime type to determine if it’s an image or not. This would actually be the preferred method to support any image type, but it may not be compatible in all systems, so use the below code with caution as it may not work in every environment. you would replace the first line with this code below.
Advanced Featherlight Jquery Plugin Fix For Images:
image: {
process: function(url){
var self = this;
var deferred = jQuery.Deferred();
fetch(url, { method: 'HEAD' })
.then(function(response) {
if(response.ok && response.headers.get('Content-Type').startsWith('image/')) {
var img = jQuery('<img>').attr('src', url).on('load', function() {
deferred.resolve(img);
}).on('error', function() {
deferred.reject('Image load error');
});
} else {
deferred.reject('Not an image MIME type');
}
})
.catch(function(error) {
deferred.reject('Error fetching image: ' + error.message);
});
return deferred.promise();
}
}
Location Of Feathelight jQuery Plugin:
This will vary based on how featherlight was implemented in your system. Many theme providers will use this for woocommerce, so there is no one specific place to find the version your website is using, unless you implemented the library yourself. Typically a quick file search for featherlight.min should return good results when searching your main directories.