Gallery display enhancements from tellyworth. fixes #6368
git-svn-id: https://develop.svn.wordpress.org/trunk@7496 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8ef66725bd
commit
cf9618758d
@ -460,10 +460,10 @@ function get_attachment_taxonomies($attachment) {
|
|||||||
function image_attachment_fields_to_edit($form_fields, $post) {
|
function image_attachment_fields_to_edit($form_fields, $post) {
|
||||||
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
|
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
|
||||||
$form_fields['post_title']['required'] = true;
|
$form_fields['post_title']['required'] = true;
|
||||||
$form_fields['post_excerpt']['label'] = __('Description');
|
$form_fields['post_excerpt']['label'] = __('Caption');
|
||||||
$form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"');
|
$form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"');
|
||||||
|
|
||||||
$form_fields['post_content']['label'] = __('Long Description');
|
$form_fields['post_content']['label'] = __('Description');
|
||||||
|
|
||||||
$thumb = wp_get_attachment_thumb_url($post->ID);
|
$thumb = wp_get_attachment_thumb_url($post->ID);
|
||||||
|
|
||||||
@ -554,11 +554,11 @@ function get_attachment_fields_to_edit($post, $errors = null) {
|
|||||||
'value' => $edit_post->post_title,
|
'value' => $edit_post->post_title,
|
||||||
),
|
),
|
||||||
'post_excerpt' => array(
|
'post_excerpt' => array(
|
||||||
'label' => __('Description'),
|
'label' => __('Caption'),
|
||||||
'value' => $edit_post->post_excerpt,
|
'value' => $edit_post->post_excerpt,
|
||||||
),
|
),
|
||||||
'post_content' => array(
|
'post_content' => array(
|
||||||
'label' => __('Long description'),
|
'label' => __('Description'),
|
||||||
'value' => $edit_post->post_content,
|
'value' => $edit_post->post_content,
|
||||||
'input' => 'textarea',
|
'input' => 'textarea',
|
||||||
),
|
),
|
||||||
|
@ -340,7 +340,19 @@ function gallery_shortcode($attr) {
|
|||||||
if ( $output != '' )
|
if ( $output != '' )
|
||||||
return $output;
|
return $output;
|
||||||
|
|
||||||
$attachments = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\"");
|
extract(shortcode_atts(array(
|
||||||
|
'orderby' => 'menu_order ASC, ID ASC',
|
||||||
|
'id' => $post->ID,
|
||||||
|
'itemtag' => 'dl',
|
||||||
|
'icontag' => 'dt',
|
||||||
|
'captiontag' => 'dd',
|
||||||
|
'columns' => 3,
|
||||||
|
'size' => 'thumbnail',
|
||||||
|
), $attr));
|
||||||
|
|
||||||
|
$id = intval($id);
|
||||||
|
$orderby = addslashes($orderby);
|
||||||
|
$attachments = get_children("post_parent=$id&post_type=attachment&post_mime_type=image&orderby=\"{$orderby}\"");
|
||||||
|
|
||||||
if ( empty($attachments) )
|
if ( empty($attachments) )
|
||||||
return '';
|
return '';
|
||||||
@ -348,16 +360,21 @@ function gallery_shortcode($attr) {
|
|||||||
if ( is_feed() ) {
|
if ( is_feed() ) {
|
||||||
$output = "\n";
|
$output = "\n";
|
||||||
foreach ( $attachments as $id => $attachment )
|
foreach ( $attachments as $id => $attachment )
|
||||||
$output .= wp_get_attachment_link($id, 'thumbnail', true) . "\n";
|
$output .= wp_get_attachment_link($id, $size, true) . "\n";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$listtag = tag_escape($listtag);
|
||||||
|
$itemtag = tag_escape($itemtag);
|
||||||
|
$captiontag = tag_escape($captiontag);
|
||||||
|
$columns = intval($columns);
|
||||||
|
|
||||||
$output = apply_filters('gallery_style', "
|
$output = apply_filters('gallery_style', "
|
||||||
<style type='text/css'>
|
<style type='text/css'>
|
||||||
.gallery {
|
.gallery {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
.gallery div {
|
.gallery-item {
|
||||||
float: left;
|
float: left;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -365,17 +382,28 @@ function gallery_shortcode($attr) {
|
|||||||
.gallery img {
|
.gallery img {
|
||||||
border: 2px solid #cfcfcf;
|
border: 2px solid #cfcfcf;
|
||||||
}
|
}
|
||||||
|
.gallery-caption {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<!-- see gallery_shortcode() in wp-includes/media.php -->
|
<!-- see gallery_shortcode() in wp-includes/media.php -->
|
||||||
<div class='gallery'>");
|
<div class='gallery'>");
|
||||||
|
|
||||||
foreach ( $attachments as $id => $attachment ) {
|
foreach ( $attachments as $id => $attachment ) {
|
||||||
$link = wp_get_attachment_link($id, 'thumbnail', true);
|
$link = wp_get_attachment_link($id, $size, true);
|
||||||
|
$output .= "<{$itemtag} class='gallery-item'>";
|
||||||
$output .= "
|
$output .= "
|
||||||
<div>
|
<{$icontag} class='gallery-icon'>
|
||||||
$link
|
$link
|
||||||
</div>";
|
</{$icontag}>";
|
||||||
if ( ++$i % 3 == 0 )
|
if ( $captiontag && trim($attachment->post_excerpt) ) {
|
||||||
|
$output .= "
|
||||||
|
<{$captiontag} class='gallery-caption'>
|
||||||
|
{$attachment->post_excerpt}
|
||||||
|
</{$captiontag}>";
|
||||||
|
}
|
||||||
|
$output .= "</{$itemtag}>";
|
||||||
|
if ( $columns > 0 && ++$i % $columns == 0 )
|
||||||
$output .= '<br style="clear: both" />';
|
$output .= '<br style="clear: both" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,7 @@ function shortcode_parse_atts($text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shortcode_atts($pairs, $atts) {
|
function shortcode_atts($pairs, $atts) {
|
||||||
|
$atts = (array)$atts;
|
||||||
$out = array();
|
$out = array();
|
||||||
foreach($pairs as $name => $default) {
|
foreach($pairs as $name => $default) {
|
||||||
if ( array_key_exists($name, $atts) )
|
if ( array_key_exists($name, $atts) )
|
||||||
|
Loading…
Reference in New Issue
Block a user