PHPackages                             newerton/fancy-box - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. newerton/fancy-box

ActiveLibrary[Image &amp; Media](/categories/media)

newerton/fancy-box
==================

fancyBox is a tool that offers a nice and elegant way to add zooming functionality for images, html content and multi-media on your webpages

06.2k↓100%2JavaScript

Since Apr 30Pushed 12y ago1 watchersCompare

[ Source](https://github.com/newerton/fancy-box)[ Packagist](https://packagist.org/packages/newerton/fancy-box)[ RSS](/packages/newerton-fancy-box/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

fancyBox
========

[](#fancybox)

fancyBox is a tool that offers a nice and elegant way to add zooming functionality for images, html content and multi-media on your webpages.

More information and examples:

License:

Copyright (c) 2012 Janis Skarnelis -

How to use
----------

[](#how-to-use)

To get started, download the plugin, unzip it and copy files to your website/application directory. Load files in the section of your HTML document. Make sure you also add the jQuery library.

```

```

Create your links with a `title` if you want a title to be shown, and add a class:

```

```

If you have a set of related items that you would like to group, additionally include a group name in the `rel` (or `data-fancybox-group`) attribute:

```

```

Initialise the script like this:

```

    $(document).ready(function() {
        $('.fancybox').fancybox();
    });

```

May also be passed an optional options object which will extend the default values. Example:

```

    $(document).ready(function() {
        $('.fancybox').fancybox({
            padding : 0,
            openEffect  : 'elastic'
        });
    });

```

Tip: Automatically group and apply fancyBox to all images:

```
$("a[href$='.jpg'],a[href$='.jpeg'],a[href$='.png'],a[href$='.gif']").attr('rel', 'gallery').fancybox();

```

Script uses the `href` attribute of the matched elements to obtain the location of the content and to figure out content type you want to display. You can specify type directly by adding classname (fancybox.image, fancybox.iframe, etc) or `data-fancybox-type` attribute:

```
//Ajax:
Example
//or
Example

//Iframe:
Example

//Inline (will display an element with `id="example"`)
Example

//SWF:
Example

//Image:
Example

```

Note, ajax requests are subject to the [same origin policy](http://en.wikipedia.org/wiki/Same_origin_policy). If fancyBox will not be able to get content type, it will try to guess based on 'href' and will quit silently if would not succeed. (this is different from previsous versions where 'ajax' was used as default type or an error message was displayed).

Advanced
--------

[](#advanced)

### Helpers

[](#helpers)

Helpers provide a simple mechanism to extend the capabilities of fancyBox. There are two built-in helpers - 'overlay' and 'title'. You can disable them, set custom options or enable other helpers. Examples:

```
//Disable title helper
$(".fancybox").fancybox({
    helpers:  {
        title:  null
    }
});

//Disable overlay helper
$(".fancybox").fancybox({
    helpers:  {
        overlay : null
    }
});

//Change title position and overlay color
$(".fancybox").fancybox({
    helpers:  {
        title : {
            type : 'inside'
        },
        overlay : {
            css : {
                'background' : 'rgba(255,255,255,0.5)'
            }
        }
    }
});

//Enable thumbnail helper and set custom options
$(".fancybox").fancybox({
    helpers:  {
        thumbs : {
            width: 50,
            height: 50
        }
    }
});

```

### API

[](#api)

Also available are event driven callback methods. The `this` keyword refers to the current or upcoming object (depends on callback method). Here is how you can change title:

```
$(".fancybox").fancybox({
    beforeLoad : function() {
        this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');

        /*
            "this.element" refers to current element, so you can, for example, use the "alt" attribute of the image to store the title:
            this.title = $(this.element).find('img').attr('alt');
        */
    }
});

```

It`s possible to open fancyBox programmatically in various ways:

```
//HTML content:
$.fancybox( 'Lorem LipsumLorem lipsum', {
    title : 'Custom Title'
});

//DOM element:
$.fancybox( $("#inline"), {
    title : 'Custom Title'
});

//Custom object:
$.fancybox({
    href: 'example.jpg',
    title : 'Custom Title'
});

//Array of objects:
$.fancybox([
    {
        href: 'example1.jpg',
        title : 'Custom Title 1'
    },
    {
        href: 'example2.jpg',
        title : 'Custom Title 2'
    }
], {
    padding: 0
});

```

There are several methods that allow you to interact with and manipulate fancyBox, example:

```
//Close fancybox:
$.fancybox.close();

```

There is a simply way to access wrapping elements using JS:

```
$.fancybox.wrap
$.fancybox.skin
$.fancybox.outer
$.fancybox.inner

```

You can override CSS to customize the look. For example, make navigation arrows always visible, change width and move them outside of area (use this snippet after including fancybox.css):

```
.fancybox-nav span {
    visibility: visible;
}

.fancybox-nav {
    width: 80px;
}

.fancybox-prev {
    left: -80px;
}

.fancybox-next {
    right: -80px;
}

```

In that case, you might want to increase space around box:

```
$(".fancybox").fancybox({
    margin : [20, 60, 20, 60]
});

```

Bug tracker
-----------

[](#bug-tracker)

Have a bug? Please create an issue on GitHub at

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/85c174c2da14b9d38c4b4b43879f379be5fbc0bb28c2e3e47d63007555eb8509?d=identicon)[newerton](/maintainers/newerton)

---

Top Contributors

[![fancyapps](https://avatars.githubusercontent.com/u/1055589?v=4)](https://github.com/fancyapps "fancyapps (156 commits)")[![newerton](https://avatars.githubusercontent.com/u/4175945?v=4)](https://github.com/newerton "newerton (4 commits)")[![mbasaglia](https://avatars.githubusercontent.com/u/2465791?v=4)](https://github.com/mbasaglia "mbasaglia (2 commits)")[![xrmx](https://avatars.githubusercontent.com/u/12932?v=4)](https://github.com/xrmx "xrmx (2 commits)")[![ChrisMBarr](https://avatars.githubusercontent.com/u/463685?v=4)](https://github.com/ChrisMBarr "ChrisMBarr (2 commits)")[![imhoffd](https://avatars.githubusercontent.com/u/236501?v=4)](https://github.com/imhoffd "imhoffd (1 commits)")[![kidwm](https://avatars.githubusercontent.com/u/822446?v=4)](https://github.com/kidwm "kidwm (1 commits)")[![markashleybell](https://avatars.githubusercontent.com/u/483470?v=4)](https://github.com/markashleybell "markashleybell (1 commits)")[![mcwehner](https://avatars.githubusercontent.com/u/48683?v=4)](https://github.com/mcwehner "mcwehner (1 commits)")[![polymorphm](https://avatars.githubusercontent.com/u/422741?v=4)](https://github.com/polymorphm "polymorphm (1 commits)")[![tamert](https://avatars.githubusercontent.com/u/1997933?v=4)](https://github.com/tamert "tamert (1 commits)")[![themire](https://avatars.githubusercontent.com/u/138376?v=4)](https://github.com/themire "themire (1 commits)")[![zzzzBov](https://avatars.githubusercontent.com/u/518319?v=4)](https://github.com/zzzzBov "zzzzBov (1 commits)")[![danwaz](https://avatars.githubusercontent.com/u/581071?v=4)](https://github.com/danwaz "danwaz (1 commits)")[![freshprince](https://avatars.githubusercontent.com/u/19355?v=4)](https://github.com/freshprince "freshprince (1 commits)")[![heldr](https://avatars.githubusercontent.com/u/134727?v=4)](https://github.com/heldr "heldr (1 commits)")[![hongaar](https://avatars.githubusercontent.com/u/205834?v=4)](https://github.com/hongaar "hongaar (1 commits)")

### Embed Badge

![Health badge](/badges/newerton-fancy-box/health.svg)

```
[![Health](https://phpackages.com/badges/newerton-fancy-box/health.svg)](https://phpackages.com/packages/newerton-fancy-box)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k22](/packages/bkwld-croppa)[marc1706/fast-image-size

fast-image-size is a PHP library that does almost everything PHP's getimagesize() does but without the large overhead of downloading the complete file.

959.4M20](/packages/marc1706-fast-image-size)[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495225.1k1](/packages/char0n-ffmpeg-php)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
