2017 © Pedro Peláez
 

symfony-bundle image-bundle

Symfony2 image Bundle

image

avro/image-bundle

Symfony2 image Bundle

  • Monday, January 7, 2013
  • by jdewit
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

AvroImageBundle

Symfony2 Image Bundle., (*1)

Easily attach images to any object and display them as a gallery, carousel, or lightbox., (*2)

Status

  • A work in progress
  • Currently only works with MongoDB and stores images in GridFS

Requirements

Installation

Download AvroImageBundle using composer

Add AvroImageBundle in your composer.json:, (*3)

{
    "require": {
        "avro/image-bundle": "*"
    }
}

Now tell composer to download the bundle by running the command:, (*4)

``` bash $ php composer.phar update avro/image-bundle, (*5)


### Enable the bundle in the kernel: ``` php // app/AppKernel.php new Avro\ImageBundle\AvroImageBundle

Add Routing

//app/config/routing, (*6)

``` yaml avro_image: resource: "@AvroImageBundle/Resources/config/routing/routing.xml", (*7)


### Add Resources Add CSS ``` html {% stylesheets output='css/compiled/app.css' filter='cssrewrite, less, ?yui_css' ... 'bundles/avroimage/css/avro-image.css' ... %} <link rel="stylesheet" href="{{ asset_url }}" type="text/css" media="screen" /> {% endstylesheets %}

Add JS ``` html {% javascripts output='js/compiled/app.js' filter='?yui_js' ... 'bundles/avroimage/js/avro-image.js' ... %} {% endjavascripts %}, (*8)


Dump your assets and watch ``` bash $ php app/console assets:install --symlink=true $ php app/console assetic:dump --watch --force

Add Mapping

Add the image reference to the object you want to rate, (*9)

``` php <?php // src/Acme/ProductBundle/Document/Product.php, (*10)

namespace Acme\ProductBundle\Document;, (*11)

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Avro\ImageBundle\Model\ImageObjectInterface;, (*12)

/** * @ODM\Document */ class Product implements ImageObjectInterface { ..., (*13)

public function __construct()
{
    $this->images = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
 * @ODM\ReferenceMany(targetDocument="Avro\ImageBundle\Document\Image", cascade={"all"}, sort={"position"="asc"})
 */
protected $images;

/**
 * Set images
 *
 * @param ArrayCollection $images
 * @return Product
 */
public function setImages(\Doctrine\Common\Collections\ArrayCollection $images)
{
    $this->images = $images;
    return $this;
}

/**
 * Get images
 *
 * @return MongoCursor $images
 */
public function getImages()
{
    return $this->images;
}

/**
 * Add images
 *
 * @param Avro\ImageBundle\Document\Image $image
 */
public function addImage(\Avro\ImageBundle\Document\Image $image)
{
    $this->images[] = $image;
    return $this;
}

/**
 * Remove image
 *
 * @param Avro\ImageBundle\Document\Image $image
 */
public function removeImage(\Avro\ImageBundle\Document\Image $image)
{
    $this->images->removeElement($image);
    return $this;
}

/**
 * Get the documents name
 */
public function getDocumentName()
{
    return 'product';
}

...

}, (*14)

Configuration Reference
-----------------------
``` yaml
    avro_image:
        db_driver: mongodb 
        carousels:
            my_carousel:
                style=twitter
                width: 300
                height: 300
                slide: true
            my_custom_carousel:
                style: custom
                template: AcmeDemoBundle:Carousel:my_carousel.html.twig

Showing Images

Render images in twitter bootstrap carousel, (*15)

html {{ carousel_render('twitter', product.images) }}, (*16)

And that's it!, (*17)

Contributing

Send in your custom templates!, (*18)

The Versions

07/01 2013

dev-master

9999999-dev http://github.com/avro/ImageBundle

Symfony2 image Bundle

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

by Joris de Wit

image