Extend I18N Gallery
I18N Gallery is extensible!
I18N Gallery offers the following hooks and filters, which can be used by other plugins to extend I18N Gallery:
- gallery-extras: action on the edit gallery page that is executed when the gallery options have been output.
- image-veto: filter function taking the arguments $name, $filename, $tags, where $name is the name of the gallery, $filename is the image file and $tags is an array of strings with the tags of this image. This function can be used to exclude images from being displayed by returning true.
Example code for a plugin extending I18N Gallery:
New Gallery Types
You can create new gallery types by adding a gallery plugin.
- create a new PHP file plugin_mytype.php in plugins/i18n_gallery, and in this file
- register the type with i18n_gallery_register('mytype', 'Name for dropdown', 'description including licensing information', 'i18n_gallery_mytype_edit', 'i18n_gallery_mytype_header', 'i18n_gallery_mytype_content'),
- create a function i18n_gallery_type_edit to display the options in the administration,
- create a function i18n_gallery_type_header to output the CSS and JS includes in the HTML header
- create a function i18n_gallery_type_content to output the gallery itself.
Here is an example for a gallery plugin file named plugin_mytype.php in the directory plugins/i18n_gallery (replace mytype with the actual name):
$gallery is an associative array with all gallery parameters. It includes all input fields as parameters (names are not prefixed mytype-).
- All fields must be named mytype-xxx.
Use helper functions from helper.php, e.g.
- i18n_gallery_check to check for general gallery settings
- i18n_gallery_needs_include to check if a file needs to be included or was already included for another gallery
- Make sure to separate your CSS into general parts (for all galleries of this type) and specific parts (e.g. size settings for the current gallery.
- If the gallery shows thumbnails you should check, if only one thumbnail should be displayed (function i18n_gallery_thumb) and hide all other thumbnails in this case.
- You should also check, if a specific picture ($pic) should be displayed.
- There are a lot of helper functions in helper.php, which can and should be used in the plugin. See one of the existing plugins for an example.