You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've written a small wrapper for lightbox that takes a few data attributes and sets the parent link to a default image if the thumbnail image isn't found. I thought you might want to include this sort of functionality in the library itself since it's easy to do and may be a common feature.
/** Lightbox wrapper to display a default image when a thumbnail isn't found.1. Add class `wLightboxWrapper` to img. 2. Set `src="#"`. 3. Add `data-src` with desired image URL.4. Add `data-err-src` with error image URL. 5. Add `data-err-href` with error image link.Note that we need to set `src` from the `data-src` otherwise the error eventmay be missed.*/functionwLightboxWrapper($img){varsrc=$img.data('src');$img.attr('src',src);$img.on('error',function(){varerrSrc=$img.data('err-src');varerrHref=$img.data('err-href');$img.attr('src',errSrc);$img.parent().attr('href',errHref);});}$(document).ready(function(){$('.wLightboxWrapper').each(function(){wLightboxWrapper($(this));});});
The text was updated successfully, but these errors were encountered:
I've written a small wrapper for lightbox that takes a few data attributes and sets the parent link to a default image if the thumbnail image isn't found. I thought you might want to include this sort of functionality in the library itself since it's easy to do and may be a common feature.
The text was updated successfully, but these errors were encountered: