markocupic / gallery-creator-bundle
gallery extension for Contao CMS
Installs: 5 538
Dependents: 2
Suggesters: 0
Security: 0
Stars: 7
Watchers: 4
Forks: 3
Open Issues: 5
Type:contao-bundle
Requires
- php: ^8.1
- contao/core-bundle: ^5.3
- jaybizzle/crawler-detect: ^1.2
- league/commonmark: ^2.3
Requires (Dev)
- 3.x-dev
- 3.1.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.x-dev
- 2.0.0-RC8
- 2.0.0-RC7
- 2.0.0-RC6
- 2.0.0-RC5
- 2.0.0-RC4
- 2.0.0-RC3
- 2.0.0-RC2
- 2.0.0-RC1
- 2.0.0-Alpha1
- 1.x-dev
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-11-03 20:15:11 UTC
README
Gallery Creator Bundle
Frontend and backend extension for Contao CMS
This extension can be used to create, display and manage photo albums in your Contao installation. The Gallery Creator Bundle offers an album listing and an album detail view. Since version 2.0.0 markdown can be used to create the album description.
Gallery.Creator.mp4
Installation
Please use the Contao Manager or run composer require markocupic/gallery-creator-bundle
in your CLI to install the extension.
CHMOD
Go to the Contao Backend Settings and select a default album owner, a default album owner group and set the default access rights
Important: If you keep the "album owner" field empty, the currently logged in backend user automatically becomes the album owner when creating a new album.
Lightbox
As a lightbox we strongly recommend Glightbox.
Simply run the composer require inspiredminds/contao-glightbox
command in your CLI.
Please ensure, that you have activated the lightbox template
in the layout settings of your theme in the Contao backend.
CSS
Gallery Creator will add the .gc-listing-view
and/or the .gc-detail-view
to the
body tag. This will help you display or hide items you don't want to show in both modes (listing- & detail-view).
/** SASS
* Do not display ce elements headline in detail mode
*
*/
body.gc-detail-view {
.ce_gallery_creator {
h2:not([class^="gc-album-detail-name"]) {
display: none;
}
}
}
Configuration
This gallery extension is shipped with a default configuration.
If you want to override these settings, you
can do this in your common configuration file located in config/config.yml
.
# config/config.yml # Gallery Creator (default settings) markocupic_gallery_creator: upload_path: 'files/gallery_creator_albums' copy_images_on_import: true read_exif_meta_data: false valid_extensions: ['jpg', 'jpeg', 'gif', 'png', 'webp', 'svg', 'svgz'] # Contao configuration contao: url_suffix: '' #....
"galleryCreatorGenerateFrontendTemplate" - Hook
Use the "galleryCreatorGenerateFrontendTemplate" hook to adapt the frontend output.
The "galleryCreatorGenerateFrontendTemplate" hook is triggered before the gallery creator front end template is parsed. It passes the content element object, the template object and the album object of the active album (if there is one). The "galleryCreatorGenerateFrontendTemplate" hook expects no return value.
<?php // src/EventListener/GalleryCreatorFrontendTemplateListener.php declare(strict_types=1); namespace App\EventListener; use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; use Contao\CoreBundle\DependencyInjection\Attribute\AsHook; use Contao\CoreBundle\Twig\FragmentTemplate; use Markocupic\GalleryCreatorBundle\Model\GalleryCreatorAlbumsModel; #[AsHook(GalleryCreatorFrontendTemplateListener::HOOK, priority: 100)] class GalleryCreatorFrontendTemplateListener { public const HOOK = 'galleryCreatorGenerateFrontendTemplate'; public function __invoke(AbstractContentElementController $contentElement, Fragmenttemplate $template, GalleryCreatorAlbumsModel|null $activeAlbum = null) { $template->set('foo', 'bar'); } }
"galleryCreatorImagePostInsert" - Hook
Use the "galleryCreatorImagePostInsert" hook to adapt the picture entity when uploading new images to an album.
The "galleryCreatorImagePostInsert" is executed right after an image has been uploaded and has been written to the database. It passes the pictures model and expects no return value.
<?php // src/EventListener/GalleryCreatorImagePostInsertListener.php declare(strict_types=1); namespace App\EventListener; use Contao\BackendUser; use Contao\CoreBundle\DependencyInjection\Attribute\AsHook; use Markocupic\GalleryCreatorBundle\Model\GalleryCreatorPicturesModel; use Symfony\Bundle\SecurityBundle\Security; #[AsHook(GalleryCreatorImagePostInsertListener::HOOK, priority: 100)] class GalleryCreatorImagePostInsertListener { public const HOOK = 'galleryCreatorImagePostInsert'; private Security $security; public function __construct(Security $security) { $this->security = $security; } public function __invoke(GalleryCreatorPicturesModel $picturesModel): void { $user = $this->security->getUser(); // Automatically add a caption to the uploaded image if ($user instanceof BackendUser && $user->name) { $picturesModel->caption = 'Holidays '.date('Y').', Photo: '.$user->name; $picturesModel->save(); } } }
Have fun!