Define own Galleryformatter style
Last updated on
30 April 2025
If you use galleryformatter, sometimes you need own style, not just a contrib Greenarrow. I'd like to answer how to add this style.
- first you need the implementation of hook_galleryformatter_styles
/** * Implementation of hook_galleryformatter_styles(). * * This hook allows other modules to create additional tab styles for * the galleryformatter module. * * @return array * An array of key => value pairs suitable for inclusion as the #options in a * select or radios form element. Each key must be the location of a css * file for a gallery formatter style. Each value should be the name of the style. */ function mymodule_galleryformatter_styles() { $gallerystyles_directory = drupal_get_path('module', 'mymodule') . '/gallerystyles'; $files = file_scan_directory($gallerystyles_directory, '/\.css$/'); $gallerystyles = array(); foreach ($files as $file) { // Skip RTL files. if (!strpos($file->name, '-rtl')) { $gallerystyles[$file->uri] = drupal_ucfirst($file->name); } } return $gallerystyles; } - add gallerystyles folder in to your theme or module
- add custom mymodule.css file.
- clean Theme registry cache table, or all cache tables
- go to your node type manage display page, and edit your image field, and set Mymodule style for image
- save
You just need to write some css code for style it.
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion