简体   繁体   English

使用PHP确定用户可以处理FancyZoom(Javascript图像缩放器)

[英]Using PHP to determine a user can handle FancyZoom (Javascript image zoomer)

I'm working on a small PHP-driven website that's so basic that I can't imagine a browser from any time in the 2000's, if not further back, would have any serious issues with it. 我正在一个小型的PHP驱动的网站上工作,该网站是如此基础,以至于我无法想象2000年代的任何时候的浏览器,即使再往前走也不会有任何严重的问题。

I added the FancyZoom Javascript image viewer, though, and it's the ONE part of my site that I can't bet my life on in terms of across-the-board compatibility, especially taking fragmented mobile browsers into account (for instance, I'm still using an iPhone 3GS, so I know luddites like me are out there). 不过,我添加了FancyZoom Javascript图像查看器,这是我网站的一个组成部分,从整体兼容性上讲,我无法下注,特别是考虑到分散的移动浏览器(例如,我仍在使用iPhone 3GS,所以我知道像我这样的卢迪特人就在那里。

I know browser/feature detection is discussed here often, but I've got a relatively specific request since I'm not an up-to-date web programmer. 我知道这里经常讨论浏览器/功能检测,但是由于我不是最新的Web程序员,所以我有一个相对具体的要求。 What specific features (or user agents, if the case may be) should I be detecting to determine whether to enable an image viewer like FancyZoom or simply leave the user with a direct image link? 我应该检测哪些特定功能(或用户代理,如果可能的话),以确定是启用像FancyZoom这样的图像查看器,还是干脆让用户拥有直接的图像链接?

I'd imagine that it should be possible to filter out a few cases where the image loader wouldn't work, without going so far as to use one of those uber-complex user agent parsers that require updates, etc. This is a really simple, specific detection problem. 我想应该可以过滤掉一些图像加载器无法工作的情况,而不必使用那些需要更新的超级复杂的用户代理解析器之一,等等。简单,特定的检测问题。

Any ideas on how to boil this down to the simplest possible features to check for would be great. 关于如何将其简化为可能要检查的最简单功能的任何想法都将是不错的。 Thanks! 谢谢!

you could do something like this to weed out old browsers 你可以做这样的事情来淘汰旧的浏览器

$browser = $_SERVER['HTTP_USER_AGENT']; 

if(preg_match('/(?i)MSIE [1-6]/',$browser) && !preg_match('/Opera/i',$browser))
 {
$image = 'Non fancy zoom';

} else

{
$image = 'fancy zoom';
} 

I have not messed with the jquery plugin your using, so I do not know what browsers it is good for etc, but you can use the below to find their browser and just write rules... 我没有弄乱您使用的jquery插件,所以我不知道它对哪些浏览器有利,等等,但是您可以使用下面的内容找到他们的浏览器并编写规则...

$browser = $_SERVER['HTTP_USER_AGENT']; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM