Ticket #10734: gallery_shortcode_style.diff
File gallery_shortcode_style.diff, 2.4 KB (added by , 15 years ago) |
---|
-
media.php
598 598 } 599 599 600 600 add_shortcode('gallery', 'gallery_shortcode'); 601 add_action ( 'template_redirect' , 'gallery_scan' ); 601 602 602 603 /** 603 604 * The Gallery shortcode. … … 677 678 678 679 $selector = "gallery-{$instance}"; 679 680 680 $output = apply_filters('gallery_style', " 681 <style type='text/css'> 682 #{$selector} { 683 margin: auto; 684 } 685 #{$selector} .gallery-item { 686 float: left; 687 margin-top: 10px; 688 text-align: center; 689 width: {$itemwidth}%; } 690 #{$selector} img { 691 border: 2px solid #cfcfcf; 692 } 693 #{$selector} .gallery-caption { 694 margin-left: 0; 695 } 696 </style> 697 <!-- see gallery_shortcode() in wp-includes/media.php --> 698 <div id='$selector' class='gallery galleryid-{$id}'>"); 681 $output = apply_filters('gallery_style', "<div id='$selector' class='gallery galleryid-{$id}'>"); 699 682 700 683 $i = 0; 701 684 foreach ( $attachments as $id => $attachment ) { 702 685 $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); 703 686 704 $output .= "<{$itemtag} class='gallery-item' >";687 $output .= "<{$itemtag} class='gallery-item' style='width:{$itemwidth}%'>"; 705 688 $output .= " 706 689 <{$icontag} class='gallery-icon'> 707 690 $link … … 724 707 return $output; 725 708 } 726 709 710 function gallery_style () { 711 712 $output = apply_filters('gallery_style', " 713 <!-- [gallery] shortcode style --> 714 <style type='text/css'> 715 .gallery { 716 margin: auto; 717 } 718 .gallery-item { 719 float: left; 720 margin-top: 10px; 721 text-align: center; 722 } 723 .gallery img { 724 border: 2px solid #cfcfcf; 725 } 726 .gallery-caption { 727 margin-left: 0; 728 } 729 </style> 730 "); 731 732 echo $output; 733 } 734 735 function gallery_scan () { 736 global $posts; 737 738 if ( !is_array ( $posts ) ) 739 return; 740 741 foreach ( $posts as $post ) { 742 if ( false !== strpos ( $post->post_content, '[gallery' ) ) { 743 add_action ( 'wp_head', 'gallery_style' ); 744 break; 745 } 746 } 747 } 748 749 727 750 /** 728 751 * Display previous image link that has the same post parent. 729 752 *