Friday, September 9, 2011

Fancy box and mvc's action result


I faced issue with mvc. The images
I'm using are stored in a database. They are served from the server
using ASP.NET MVC 3. Therefore, my image links look like this:
<a href="/Photo/Image/4" rel="gallery"><img src="/Photo/Image/4"
alt="foo" /></a>

The fancybox script uses regex to determine if the link is an image.
Well, it fails on this, and winds up showing you the raw data in the
image file. I figured out what to do by reading the javascript. All I
needed to do was add 'type': 'image' to my options. My script looks
like this:
$(".gallery a").fancybox({
'zoomSpeedIn': 300,
'hideOnContentClick': true,
'zoomSpeedOut': 300,
'overlayOpacity': .8,
'type': 'image'

No comments: