Opened 12 years ago
Last modified 2 years ago
#29379 new enhancement
Add a hook to filter gallery classes
| Reported by: | grosbouff | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | Future Release |
| Component: | Gallery | Version: | 3.9.2 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
Hi, it would be really great to be allowed to filter the gallery classes.
Here's what I suggest :
instead of :
$size_class = sanitize_html_class( $atts['size'] );
$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
rather use
$classes_str = null;
$classes = array(
'gallery',
'galleryid-'.$id,
'gallery-columns-'.$columns,
'gallery-size-'.sanitize_html_class( $atts['size'] )
);
$classes = apply_filters('gallery_classes',$classes,$attr);
if (!empty($classes)){
$classes = array_filter($classes);
$classes_str = " class='".implode(' ',$classes)."'";
}
$size_class = sanitize_html_class( $atts['size'] );
$gallery_div = "<div id='$selector' $classes_str>";
Attachments (2)
Change History (6)
#3
@
4 years ago
- Keywords needs-refresh added; needs-docs removed
- Milestone → Future Release
- Priority normal → low
29379.diff needs to be refreshed against the current code base.
While gallery blocks are the preferred way to implement galleries now and they do not use gallery_shortcode() directly, I think this is a reasonable change to make. Adding a classes attribute to $attr may also make sense to accompany this.
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Added actionhook like in example above.