Ticket #26695: 26695_v2.diff
File 26695_v2.diff, 6.2 KB (added by , 11 years ago) |
---|
-
wp-admin/js/theme.js
474 474 if ( image.width && image.width <= 300 ) { 475 475 el.addClass( 'small-screenshot' ); 476 476 } 477 }, 478 479 // Setups an image gallery using the theme screenshots supplied by a theme 480 screenshotGallery: function() { 481 var el, img, 482 screenshots = $( '.theme-screenshots' ); 483 484 // Select the first item 485 screenshots.find( '.thumb' ).first().addClass( 'selected' ); 486 487 // Clicking on a screenshot thumbnail drops it 488 // at the top of the stack in a larger size 489 screenshots.on( 'click', 'div.thumb', function() { 490 el = $( this ); 491 img = $( this ).find( 'img' ).attr( 'src' ); 492 493 // Change src attribute of first image 494 screenshots.find( '.screenshot' ).first().find( 'img' ).fadeOut(130, function() { 495 $(this).attr('src',img); 496 }).fadeIn(300); 497 // Mark the new image as 'selected' 498 el.siblings( '.selected' ).removeClass( 'selected' ); 499 el.addClass( 'selected' ); 500 }); 477 501 } 478 502 }); 479 503 … … 696 720 697 721 this.overlay.render(); 698 722 this.$overlay.html( this.overlay.el ); 723 this.overlay.screenshotGallery(); 699 724 700 725 // Bind to theme:next and theme:previous 701 726 // triggered by the arrow keys … … 1265 1290 self.view.trigger( 'theme:close' ); 1266 1291 }); 1267 1292 1268 themes.router.on( 'route:upload', function( ) {1293 themes.router.on( 'route:upload', function( slug ) { 1269 1294 $( 'a.upload' ).trigger( 'click' ); 1270 1295 }); 1271 1296 -
wp-admin/themes.php
193 193 $aria_name = esc_attr( $theme['id'] . '-name' ); 194 194 ?> 195 195 <div class="theme<?php if ( $theme['active'] ) echo ' active'; ?>" tabindex="0" aria-describedby="<?php echo $aria_action . ' ' . $aria_name; ?>"> 196 <?php if ( ! empty( $theme['screenshot'][0] ) ) { ?>196 <?php if ( ! empty( $theme['screenshot'][0][0] ) ) { ?> 197 197 <div class="theme-screenshot"> 198 <img src="<?php echo $theme['screenshot'][0] ; ?>" alt="" />198 <img src="<?php echo $theme['screenshot'][0][0]; ?>" alt="" /> 199 199 </div> 200 200 <?php } else { ?> 201 201 <div class="theme-screenshot blank"></div> … … 270 270 */ 271 271 ?> 272 272 <script id="tmpl-theme" type="text/template"> 273 <# if ( data.screenshot[0] ) { #>273 <# if ( data.screenshot[0][0] ) { #> 274 274 <div class="theme-screenshot"> 275 <img src="{{ data.screenshot[0] }}" alt="" />275 <img src="{{ data.screenshot[0][0] }}" alt="" /> 276 276 </div> 277 277 <# } else { #> 278 278 <div class="theme-screenshot blank"></div> … … 315 315 </div> 316 316 <div class="theme-about"> 317 317 <div class="theme-screenshots"> 318 <# if ( data.screenshot[0] ) { #> 319 <div class="screenshot"><img src="{{ data.screenshot[0] }}" alt="" /></div> 318 <# if ( data.screenshot[0][0] ) { #> 319 <div class="screenshot"><img src="{{ data.screenshot[0][0] }}" alt="" /></div> 320 <# 321 if ( _.size( data.screenshot[0] ) > 1 ) { 322 _.each ( data.screenshot[0], function( image ) { 323 #> 324 <div class="screenshot thumb"><img src="{{ image }}" alt="" /></div> 325 <# 326 }); 327 } 328 #> 320 329 <# } else { #> 321 330 <div class="screenshot blank"></div> 322 331 <# } #> -
wp-includes/class-wp-theme.php
882 882 * @return mixed Screenshot file. False if the theme does not have a screenshot. 883 883 */ 884 884 public function get_screenshot( $uri = 'uri' ) { 885 $screenshot = $this->cache_get( 'screenshot' ); 886 if ( $screenshot ) { 885 $screenshotsArr = array(); 886 $screenshots = $this->cache_get( 'screenshots' ); 887 if ( $screenshots ) { 887 888 if ( 'relative' == $uri ) 888 return $screenshot; 889 return $this->get_stylesheet_directory_uri() . '/' . $screenshot; 890 } elseif ( 0 === $screenshot ) { 889 return $screenshots; 890 else { 891 foreach ( $screenshots as $screenshot ) 892 array_push( $screenshotsArr, $this->get_stylesheet_directory_uri() . '/' . $screenshot ); 893 return $screenshotsArr; 894 } 895 } elseif ( 0 === $screenshots ) { 891 896 return false; 892 897 } 893 894 foreach ( array( 'png', 'gif', 'jpg', 'jpeg' ) as $ext ) { 895 if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) { 896 $this->cache_add( 'screenshot', 'screenshot.' . $ext ); 897 if ( 'relative' == $uri ) 898 return 'screenshot.' . $ext; 899 return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext; 898 $relativePathScreenshotsArray=array(); 899 $absolutePathScreenshotsArray=array(); 900 $allowedExtensions = array( 'png', 'gif', 'jpg', 'jpeg' ); 901 foreach ( $allowedExtensions as $ext ) { 902 if ( file_exists( $this->get_stylesheet_directory() . '/screenshot.' . $ext ) ) { 903 array_push( $relativePathScreenshotsArray, 'screenshot.' . $ext ); 904 array_push( $absolutePathScreenshotsArray, $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext ); 905 break; 900 906 } 901 907 } 902 903 $this->cache_add( 'screenshot', 0 ); 904 return false; 908 if ( file_exists($this->get_stylesheet_directory() . '/screenshots' ) ) { 909 $files = (array) self::scandir( $this->get_stylesheet_directory() . '/screenshots', $allowedExtensions ); 910 $extraScreenshots = array(); 911 $fileCounter = 0; 912 foreach ( $files as $name => $absPath) { 913 if ( substr( $name, 0, -5 ) == 'screenshot-' && !in_array( substr( $name, 0, -4 ), $extraScreenshots ) ) { 914 $fileCounter++; 915 array_push( $extraScreenshots, 'screenshot-' . $fileCounter ); 916 } 917 } 918 foreach ( $extraScreenshots as $screenshot ) { 919 foreach ( $allowedExtensions as $ext ) { 920 if ( file_exists( $this->get_stylesheet_directory() . '/screenshots/' . $screenshot . '.' . $ext ) ) { 921 array_push( $relativePathScreenshotsArray, '/screenshots/' . $screenshot . '.' . $ext ); 922 array_push( $absolutePathScreenshotsArray, $this->get_stylesheet_directory_uri() . '/screenshots/' . $screenshot . '.' . $ext ); 923 break; 924 } 925 } 926 } 927 } 928 $this->cache_add( 'screenshots', $relativePathScreenshotsArray ); 929 if ( 'relative' == $uri ) 930 return $relativePathScreenshotsArray; 931 return $absolutePathScreenshotsArray; 905 932 } 906 933 907 934 /**