What steps will reproduce the problem?
Add [gallery exclude="AttachmentID"] to a post and attempt to exclude an
attachment already attached to the post, or add [gallery
include="AttachmentID"] and attempt to include any attachment.
What is the expected output? What do you see instead?
With both exclude and include we expect the default WP functionality to work,
such that attachments can be either exclude or include (but not both at the
same time)
What version of the product are you using? On what operating system?
WP 3.3.1 on Unix
Please provide any additional information below.
To add support for exclude and include, I patched
carrington-core/attachment.php by replacing lines 43 - 55 with:
extract(shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'thumbnail',
'include' => '',
'exclude' => ''
), $attr));
$id = intval($id);
if ( 'RAND' == $order )
$orderby = 'none';
if ( !empty($include) ) {
$include = preg_replace( '/[^0-9,]+/', '', $include );
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( !empty($exclude) ) {
$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
} else {
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
}
Original issue reported on code.google.com by jonat...@regeimbal.net on 16 Jan 2012 at 11:23
Original issue reported on code.google.com by
jonat...@regeimbal.net
on 16 Jan 2012 at 11:23