Ticket #6380: 6380-style.diff
| File 6380-style.diff, 2.2 KB (added by andy, 5 years ago) |
|---|
-
wp-includes/media.php
340 340 if ( $output != '' ) 341 341 return $output; 342 342 343 extract(shortcode_atts(a rray(343 extract(shortcode_atts(apply_filters('gallery_defaults', array( 344 344 'orderby' => 'menu_order ASC, ID ASC', 345 345 'id' => $post->ID, 346 346 'itemtag' => 'dl', … … 348 348 'captiontag' => 'dd', 349 349 'columns' => 3, 350 350 'size' => 'thumbnail', 351 ) , $attr));351 )), $attr)); 352 352 353 353 $id = intval($id); 354 354 $orderby = addslashes($orderby); … … 369 369 $captiontag = tag_escape($captiontag); 370 370 $columns = intval($columns); 371 371 $itemwidth = $columns > 0 ? floor(100/$columns) : 100; 372 373 $output = apply_filters('gallery_style', " 374 <style type='text/css'> 375 .gallery { 376 margin: auto; 377 } 378 .gallery-item { 379 float: left; 380 margin-top: 10px; 381 text-align: center; 382 width: {$itemwidth}%; } 383 .gallery img { 384 border: 2px solid #cfcfcf; 385 } 386 .gallery-caption { 387 margin-left: 0; 388 } 389 </style> 372 373 $output = " 390 374 <!-- see gallery_shortcode() in wp-includes/media.php --> 391 <div class='gallery'>" );375 <div class='gallery'>"; 392 376 393 377 foreach ( $attachments as $id => $attachment ) { 394 378 $link = wp_get_attachment_link($id, $size, true); 395 $output .= "<{$itemtag} class='gallery-item' >";379 $output .= "<{$itemtag} class='gallery-item' style='width:{$itemwidth}%'>"; 396 380 $output .= " 397 381 <{$icontag} class='gallery-icon'> 398 382 $link … … 415 399 return $output; 416 400 } 417 401 402 function gallery_style() { 403 ?> 404 405 <style type='text/css'> 406 .gallery { 407 margin: auto; 408 } 409 .gallery-item { 410 float: left; 411 margin-top: 10px; 412 text-align: center; 413 } 414 .gallery img { 415 border: 2px solid #cfcfcf; 416 } 417 .gallery-caption { 418 margin-left: 0; 419 } 420 </style> 421 422 <?php 423 } 424 425 function gallery_scan() { 426 global $posts; 427 428 if ( !is_array($posts) ) 429 return; 430 431 foreach ( $posts as $post ) { 432 if ( false !== strpos($post->post_content, '[gallery') ) { 433 add_action('wp_head', 'gallery_style'); 434 break; 435 } 436 } 437 } 438 439 add_action('template_redirect', 'gallery_scan'); 440 418 441 function previous_image_link() { 419 442 adjacent_image_link(true); 420 443 }
