Opened 10 years ago
Last modified 7 months ago
#29379 new enhancement
Add a hook to filter gallery classes
Reported by: | grosbouff | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | low |
Severity: | normal | Version: | 3.9.2 |
Component: | Gallery | Keywords: | has-patch |
Focuses: | Cc: |
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)
#1
@
9 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
#3
@
2 years ago
- Keywords needs-refresh added; needs-docs removed
- Milestone set to Future Release
- Priority changed from normal to 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.
Added actionhook like in example above.