PHPackages                             zertz/photo-bundle - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. zertz/photo-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

zertz/photo-bundle
==================

Symfony ZertzPhotoBundle

014PHP

Since Jan 24Pushed 11y agoCompare

[ Source](https://github.com/Zertz/ZertzPhotoBundle)[ Packagist](https://packagist.org/packages/zertz/photo-bundle)[ RSS](/packages/zertz-photo-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

ZertzPhotoBundle
================

[](#zertzphotobundle)

This bundle provides an easy to use platform to automatically resize photos on upload and display them back to the user.

### Features

[](#features)

- Photo management
- Customizable thumbnails
- Resizing

### Upcoming features

[](#upcoming-features)

- Batch resize from the command-line

1. Requirements

---

1. Symfony 2.2 **Although it wasn't tested, it should also work with 2.1**
2. Doctrine 2

2. Installation

---

In composer.json, add:

```
"require": {
    "zertz/photo-bundle": "dev-master"
}

```

Run an update to install the bundle:

```
php composer.phar update zertz/photo-bundle

```

3. Configuration

---

### AppKernel.php

[](#appkernelphp)

Enable the bundle:

```
public function registerBundles()
{
    $bundles = array(
        new Zertz\PhotoBundle\ZertzPhotoBundle(),
    );
}

```

### config.yml

[](#configyml)

Add the following lines:

```
# Twig Configuration
twig:
    form:
        resources:
            - ZertzPhotoBundle:Form:fields.html.twig

# ZertzPhotoBundle Configuration
zertz_photo:
    directory: /path/to/save/to
    domain: http://img.yourdomain.com
    quality: 70
    formats:
        small:
            size: { width: 140 , height: 87 }
        medium:
            size: { height: 175 }
        large:
            size: { width: 635 }
            quality: 90

```

**Note**

> `directory` and `domain` keys are **required**. For JPEG photos, the `quality`setting is customizable, but **defaults** to 70.

**Formats**

> `formats` are customizable and the `size` property may contain one of, or both, `width` and `height`. The photo will automatically be resized and the aspect ratio is always maintained. For JPEG photos, the **optional** `quality`setting overrides the global `quality` setting.

> If no `formats` are defined, then the original photo is simply uploaded.

### Extend the Photo class

[](#extend-the-photo-class)

This bundle provides the basics for persisting a photo object to the database. It is your role however to extend the `Photo` class and add any fields you deem useful.

To get started, your entity class should look like this:

```
