Title: Gallery Shortcode options.
Last modified: August 19, 2016

---

# Gallery Shortcode options.

 *  [minute44](https://wordpress.org/support/users/minute44/)
 * (@minute44)
 * [17 years, 12 months ago](https://wordpress.org/support/topic/gallery-shortcode-options/)
 * Okay,
 * I’m absolutely itching to use the new gallery shortcode feature in 2.5 but I 
   haven’t yet because I do not wish to compromise the integrity of my markup.
 * At the moment my site validates as XHTML 1.0 Strict and I’m serious about web
   standards and best practices. The gallery shortcode feature is, in theory, a 
   phenominal addition to WordPress with one exception; The code it inserts forces
   you to use inline styles.
 * Not only does this go aginst the golden rule of seperation of content and style,
   it causes my markup to lose it’s validity as style isn’t allowed to be used in
   this way in the strict doctype.
 * My question is: How , if at all, can I stop the shortcode inserting in-line styles
   so I can use my global stylesheet to format my galleries?
 * thanks
 * Dan

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Justin Tadlock](https://wordpress.org/support/users/greenshady/)
 * (@greenshady)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/gallery-shortcode-options/#post-735844)
 * I wrote a plugin to handle the invalid XHTML and style it inserts into the page.
   It’s still in beta but should work:
    [Cleaner gallery plugin](http://justintadlock.com/archives/2008/04/13/cleaner-wordpress-gallery-plugin)
 *  [Edouard Duplessis](https://wordpress.org/support/users/eduplessis/)
 * (@eduplessis)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/gallery-shortcode-options/#post-736077)
 * I’ve modify the gallery shortcode to do a better and a cleaner job
 * here’s the code
    wp-includes/media.php line 384
 *     ```
       function gallery_shortcode($attr) {
       	global $post;
   
       	// Allow plugins/themes to override the default gallery template.
       	$output = apply_filters('post_gallery', '', $attr);
       	if ( $output != '' )
       		return $output;
   
       	// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
       	if ( isset( $attr['orderby'] ) ) {
       		$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
       		if ( !$attr['orderby'] )
       			unset( $attr['orderby'] );
       	}
   
       	extract(shortcode_atts(array(
       		'order'      => 'ASC',
       		'orderby'    => 'menu_order ID',
       		'id'         => $post->ID,
       		'itemtag'    => '',
       		'icontag'    => '',
       		'captiontag' => '',
       		'columns'    => 4,
       		'size'       => 'thumbnail',
       	), $attr));
   
       	$id = intval($id);
       	$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
   
       	if ( empty($attachments) )
       		return '';
   
       	if ( is_feed() ) {
       		$output = "\n";
       		foreach ( $attachments as $id => $attachment )
       			$output .= wp_get_attachment_link($id, $size, true) . "\n";
       		return $output;
       	}
   
       	$listtag = tag_escape($listtag);
       	$itemtag = tag_escape($itemtag);
       	$captiontag = tag_escape($captiontag);
       	$columns = intval($columns);
       	$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
   
       	foreach ( $attachments as $id => $attachment ) {
       		$link = wp_get_attachment_image($id, $size, true);
       		$output .= '<a href="'.wp_get_attachment_url($id).'">'.$link.'</a>';
       	}
   
       	$output .= "<br style='clear: both;' />";
   
       	return $output;
       }
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Gallery Shortcode options.’ is closed to new replies.

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [gallery](https://wordpress.org/support/topic-tag/gallery/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [Edouard Duplessis](https://wordpress.org/support/users/eduplessis/)
 * Last activity: [17 years, 6 months ago](https://wordpress.org/support/topic/gallery-shortcode-options/#post-736077)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
