Git Product home page Git Product logo

cakegallery's Introduction

Cake Gallery

CakeGallery is a cakephp plugin to manage galleries, albums and pictures

Album page

DEMO: http://galleryopenshift-cakeupload.rhcloud.com/gallery

DEMO2 (Video): https://www.youtube.com/watch?v=AhU16ji_i9g

With CakeGallery you can:

  • Create Albums
  • Add tags, title and status (published or drafts) to albums
  • Upload multiple pictures at the same time
  • Create multiple versions for your pictures (thumbnails, crop, rezise, etc)
  • Integrate any album with any other Model in your application

Requirements

To use CakeGallery you need the following requirements

  • CakePHP 2.x application
  • PHP 5.3+ (bundled GD 2.0.28+ for image manipulation)
  • MySQL
  • Apache

Version

1.1.2


Before start

  • Make sure that your app/webroot/files folder is writtable

Wizzard Installation (recommended)

  • Clone or Download the Zip file from Github
  • Copy the Gallery folder to your app plugins folder: app/Plugin/
  • Make sure that your app/Plugin/Gallery/Config folder is writtable (For installation only)
  • Open your app/Config/bootstrap.php file and add the following code
CakePlugin::load(array(
'Gallery' => array(
    'bootstrap' => true,
    'routes' => true
    )));
  • To finish the installation go to your browser and type http://your-app-url/gallery and follow the wizzard

Manual installation

  • Clone or Download the Zip file from Github
  • Copy the Gallery folder to your app plugins folder: app/Plugin/
  • Rename the app/Plugin/Gallery/Config/config.php.install file to config.php
  • Import the SQL file app/Plugin/Gallery/Config/cakegallery.sql to your database
  • Open your app/Config/bootstrap.php file and add the following code
CakePlugin::load(array(
'Gallery' => array(
    'bootstrap' => true,
    'routes' => true
    )));
  • Create a gallery folder inside app/webroot/files and give it writable permissions. (app/webroot/files/gallery)

  • Check at http://your-app-url/gallery to see your plugin working.


Features


How to attach a gallery to a model?

Integrating Gallery with a model of your application is very simple and takes only seconds, and the best is you do not need to change your database. To begin open the model you want to attach a gallery, in this example will be Product.php

Class Product extends AppModel{
    public $name = 'Product';
}

Now you just need to add the $actsAs attribute in your model:

Class Product extends AppModel{
	public $name = 'Product';
	public $actsAs = 'Gallery.Gallery';
}

And its done! To list all galleries attached to a Product, you can do something like this:

$this->Product->id = 10;
$this->Product->getGallery();

How to create a new gallery attached with a model?

Every Picture that have Gallery attached at it already have 1 gallery to start uploading files. To link to a Picture gallery is quite simple:
Using the CakePHP Html helper:

echo $this->Html->link('New gallery', array(
		'controller' => 'gallery',
		'action' => 'upload',
		'plugin' => 'gallery',
		'model' => 'product',
		'model_id' => $product_id
		));

If you don't want to use the Html helper you can link to this pattern: /your_app/gallery/upload/{model}/{model_id}


How to create a standalone gallery? (Non-related gallery)

You can create a gallery that don't belongs to any model, a standalone gallery. To create one of those you will use the same example as above, but passing the model and the model_id as NULL:

echo $this->Html->link('New gallery', array(
		'controller' => 'gallery',
		'action' => 'upload',
		'plugin' => 'gallery',
		'model' => null,
		'model_id' => null
		));

How to change image resize dimensions?

All configuration related to images you can find at app/Plugin/Gallery/Config/bootstrap.php

$config = array(
	'App' => array(
		# Choose what theme you want to use:
		# You can find all themes at Gallery/webroot/css/themes
		# Use the first name in the file as a parameter, eg: cosmo.min.css -> cosmo
		'theme' => 'cosmo'
	),
	'File' => array(
		# Max size of a file (in megabytes (MB))
		'max_file_size' => '20',

		# What king pictures the user is allowed to upload?
		'allowed_extensions' => array('jpg','png','jpeg','gif')
	),
	'Pictures' => array(
		# Resize original image. If you dont want to resize it, you should set a empty array, E.G: 'resize_to' => array()
		# Default configuration will resize the image to 1024 pixels height (and unlimited width)
		'resize_to' => array(0, 1024, false),

		# Set to TRUE if you want to convert all png files to JPG (reduce significantly image size)
		'png2jpg' => true,

		# Set the JPG quality on each resize.
		# The recommended value is 85 (85% quality)
		'jpg_quality' => 85,


		# List of additional files generated after upload, like thumbnails, banners, etc
		'styles' => array(
			'small' => array(50, 50, true), # 50x50 Cropped
			'medium' => array(255, 170, true), # 255#170 Cropped
			'large' => array(0, 533, false) # 533 pixels height (and unlimited width)
			)
		)
	);
	Configure::write('GalleryOptions', $config);	

You can create more styles on styles array of modify the default size of the defaults

PS: don't modify the default names as medium or small. This files are used by the plugin.

cakegallery's People

Contributors

hugodias avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.