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
By default Colorbox uses a URL regexp to treat certain content as a photo, so for example .jpg, .png, .svg, etc all end up in an IMG tag. And the photo:true option overrides the regexp to allow other URLs to be treated as a photo: http://www.jacklmoore.com/colorbox/#setting-photo
However there isn't an option to NOT treat content as a photo. My use case is an SVG file that needs to load as an SVG tag, not as an IMG tag. It would be great if the photo option had 3 values:
unset (default) to use the regexp to guess whether content was a photo or not
photo:true to force content to be treated as a photo
photo:false to force content to NOT be treated as a photo
A workaround is to explicitly set the photoRegex option to exclude the URLs you don't want treated as photos:
another workaround would be to rename the .svg file to something else, but that means the content-type is wrong, a server/CDN may not compress it, you can't link directly the file (non-javascript fallback), etc.
The text was updated successfully, but these errors were encountered:
Good job changing the photoRegex, that was the right way to work around that. The photoRegex doesn't have to be complicated if you know it's not a photo (e.g. /.^/). I like your suggestion, but I'm probably not going to make API changes at this point.
By default Colorbox uses a URL regexp to treat certain content as a photo, so for example
.jpg, .png, .svg
, etc all end up in an IMG tag. And the photo:true option overrides the regexp to allow other URLs to be treated as a photo:http://www.jacklmoore.com/colorbox/#setting-photo
However there isn't an option to NOT treat content as a photo. My use case is an SVG file that needs to load as an SVG tag, not as an IMG tag. It would be great if the photo option had 3 values:
A workaround is to explicitly set the photoRegex option to exclude the URLs you don't want treated as photos:
$('A.gallery').colorbox({rel:'gal', photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr)((#|\?).*)?$/i});
another workaround would be to rename the
.svg
file to something else, but that means the content-type is wrong, a server/CDN may not compress it, you can't link directly the file (non-javascript fallback), etc.The text was updated successfully, but these errors were encountered: