Default parameters/attributes for post gallery shortcode
-
I’d like a simple method to set default parameters/attributes for post gallery shortcode, even if I have to write my own plugin. In my case, I wanted all galleries to link directly to the files themselves by default. Unfortunately, there is no way to simply reference and return the attributes.
Here’s the method I’m currently using by editing wp-includes/media.php:
function gallery_shortcode($attr) { global $post, $wp_locale; static $instance = 0; $instance++; //KRG: Added for Arkmagia Gallery Shortcode. // Allow plugins/themes to override the default gallery attributes. $attr = apply_filters('post_gallery_attr', '', $attr); // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) return $output; ...
I then have a plugin to set the default params:
add_filter('post_gallery_attr', 'arkmagia_gallery_shortcode'); function arkmagia_gallery_shortcode($attr) { if ( !isset( $attr['link'] ) ) { $attr['link'] = 'file'; } return $attr; }
Though there is also another problem in that if I wanted any [gallery] instances to link to actual attachment pages, there is no explicit ‘link’ attribute value for that…
Any thoughts? Thanks for reading!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Default parameters/attributes for post gallery shortcode’ is closed to new replies.