Coder Social home page Coder Social logo

cakegallery's Introduction

Cake Gallery

![Gitter](https://badges.gitter.im/Join Chat.svg)

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

Album page

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, resize, etc)
  • Integrate any album with any other Model in your application

Videos and Resources

Installing: https://www.youtube.com/watch?v=OEgVQQTaWkE - Portuguese

Features: https://www.youtube.com/watch?v=3gHRnCI2vHE

DEMO (Old version): http://galleryopenshift-cakeupload.rhcloud.com/gallery


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

2.0.0


Before start

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

Wizard 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 writable (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 wizard

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.


FAQ


The images are not showing up

If you are using windows , have a chance of the images are not being rendered. This will happen because of windows directory separator. To fix it you can use this solution: http://stackoverflow.com/a/4095765/708385

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 = array('Gallery.Gallery');
}

And its done! Now, when you search for this object in database, its pictures will be automatically retrieved from the plugin:

$product = $this->Product->findById(10);
//
// array(
//   'Product' => array(
//     'id' => '1',
//     'name' => 'My Product',
//     'price' => '29.00'
//   ),
//   'Gallery' => array(
//     'Album' => array(
//       ...
//     ),
//     'Picture' => array(
//       ...
//     ),
//     'numPictures' => (int) 2
//   )
// )

If you want to manually call for the pictures you will want to disable the automatic feature and call it yourself:

public $actsAs = array('Gallery.Gallery' => array('automatic' => false));
// Anycontroller.php
$this->Product->id = 10;
$this->Product->getGallery();

How to create a new gallery attached with a model?

You should use the Gallery link helper. It is very easy to use.

  1. Specify the Gallery helper in your controller
  2. Use the gallery link helper passing a model and id
# ProductsController.php
class ProductsController extends AppController {
	public $helpers = array('Gallery.Gallery');
}
# app/View/Products/view.ctp
echo $this->Gallery->link('product', 10);

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 no arguments are needed

# anyview.ctp
echo $this->Gallery->link();

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 don't 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 as many styles you want, just add in the styles array, and future versions will be created on uploading.

PS: DO NOT modify the default names as medium or small. You can safely modify the width, height and action but the names are used by the plugin, so don't change then.

cakegallery's People

Contributors

gitter-badger avatar hugodias avatar ptica avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cakegallery's Issues

CakePHP 3 ?

Hi,

I would like to know if you plan to make this plugin compatible with CakePHP 3.
Your plugin is awesome and I woud love to use it.

If not, do you know any alternative ?

Thanks

Server compatibility while generating token

Hey,

I had a problem while uploading photos something was breaking, after some debuggin I found that my server is not compatible with some functions running when generating token in Component/UtilComponent.php

What I've done to fix this is change the crypto_rand_secure($min, $max) to:

public function crypto_rand_secure($min, $max)
{
    return md5(uniqid(mt_rand(), true));
}

Helper error on fresh clone

I just cloned this repo into my project and I get them Warning immediately.

Warning (512): Method GalleryHelper::new_gallery_button does not exist [CORE/Cake/View/Helper.php, line 192]

I checked the file here on github as well and that function does not exist.

BUG Deletando Albuns

Boa tarde Hugo,

No meu projeto localhost o cakegallery funciona perfeitamente, quando eu subi o projeto e tudo, os albuns
apagam depois de um certo tempo, algo parecido já aconteceu com voce?

Eu ja importei o projeto novo novamente, onde não fiz nenhuma alteração e nenhuma tradução, e mesmo assim
continua apagando, voce sabe se isso tem acontecido? Ou sabe o porque?

Att.
Renato Martins

Cakegallery - error message

Dear Hugo,
thanks a lot for your nice work. One question:
i used gallery associated to a model and i see very well picture in the view and in the index. In the index i have a list of several occurance of id and so i see several pictures.
But in this last case even if all is running well, i have also message:
"Undefined index: Artist [APP/Plugin/Gallery/Model/Behavior/GalleryBehavior.php, line 13".
What may be wrong?

Best wishes
Monica

URL barra invertida

problema e na URL das imagens esta com as barras invertidas desse modo a mesma nao e renderizada na view ficando
/teste/files\gallery\1\medium-F8S3MTHeSLNijD1OneEiQc2xzx5YW1Oc.jpg
tando para as imagens quanto para os albuns

Thank you

Dear Hugo,
thanks a lot for your nice work. Two remarks:

  1. With my xampp on windows the DS get backslash instead of slashes, so I had to change this.
  2. The link "new gallery" doesn't work with the Html-Helper, I had to do the link manually.
    I hope you understand. Sorry, my english ist terrible.
    Best wishes from Germany
    Gregor

Add the feature to include legends in each photo

How this could work:

On the upload route "gallery/upload/$id" should have a space right bellow the pictures to include a legend. I think that an editable container (http://vitalets.github.io/x-editable/) is the best option to do this so we'll be keeping the sortable feature for organizing the pictures plus the feature to include legends for each one of those.

Maybe something like that:
screenshot 2015-06-05 10 28 41

Undefined index: Picture

In the following files:
APP/Plugin/Gallery/Controller/AlbumsController.php, line 57
APP/Plugin/Gallery/View/Albums/upload.ctp, line 192

If you upload database entries and images are uploaded but the view doesn't show them.

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.